﻿Imports System.IO
Public Class AbilityEditor
    Private Const VertScrollBar As Int32 = &H115
    Private Const VertScrollBar_Btm As Int32 = 7
    Private AbilityData As String
    Private Declare Auto Function SendMessage Lib "user32.dll" (ByVal hwnd As IntPtr, ByVal wMsg As Int32, ByVal wParam As Int32, ByVal lParam As Int32) As Int32
    Public Function GetFileContents(ByVal FullPath As String, _
             Optional ByRef ErrInfo As String = "") As String

        Dim strContents As String
        Dim objReader As StreamReader
        Try
            objReader = New StreamReader(FullPath)
            strContents = objReader.ReadToEnd()
            Return strContents
            objReader.Close()
            objReader.Dispose()
        Catch Ex As Exception
            ErrInfo = Ex.Message
            MsgBox(ErrInfo, MsgBoxStyle.Critical, "ERROR!")
            Return ""
        End Try
    End Function
    Public Function SaveTextToFile(ByVal strData As String, _
     ByVal FullPath As String, _
       Optional ByVal ErrInfo As String = "") As Boolean
        Dim bAns As Boolean = False
        Dim trynum As Short = 1
        Dim objReader As StreamWriter
        While bAns = False
            Try
                objReader = New StreamWriter(FullPath)
                objReader.Write(strData)
                objReader.Close()
                bAns = True
            Catch Ex As Exception
                ErrInfo = Ex.Message
                If trynum = 1000 Then
                    MsgBox(ErrInfo, MsgBoxStyle.Critical, "ERROR!")
                    bAns = True
                End If
            End Try
        End While
        Return bAns
    End Function
    Public Sub SND(ByVal Txt As String)
        OUTPUT.Select(Len(OUTPUT.Text), 0)
        Txt = "/B " + Txt + "/B"
        Dim Switches As Integer = -1
        Dim TempStr As String
        Dim TempStr2 As String
        Dim TempInt As Integer
        Dim TempInt2 As Integer = 0
        For TempInt = 1 To Len(Txt) Step 1
            TempStr = Mid(Txt, TempInt, 1)
            If TempStr = "/" Then
                If Mid(Txt, TempInt, 2) = "/B" Then
                    If TempInt2 <> 0 Then
                        TempStr2 = Mid(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Txt, "/b", ""), "/B", ""), "/g", ""), "/G", ""), "/m", ""), "/M", ""), "/w", ""), "/W", ""), "/y", ""), "/Y", ""), "/z", ""), "/Z", ""), "/c", ""), "/C", ""), "/r", ""), "/R", ""), TempInt2 - Switches * 2, TempInt - TempInt2 - 2)
                        OUTPUT.SelectedText = TempStr2
                    End If
                    OUTPUT.SelectionColor = Color.FromArgb(&HFF)
                    TempInt2 = TempInt
                    Switches += 1
                ElseIf Mid(Txt, TempInt, 2) = "/b" Then
                    If TempInt2 <> 0 Then
                        TempStr2 = Mid(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Txt, "/b", ""), "/B", ""), "/g", ""), "/G", ""), "/m", ""), "/M", ""), "/w", ""), "/W", ""), "/y", ""), "/Y", ""), "/z", ""), "/Z", ""), "/c", ""), "/C", ""), "/r", ""), "/R", ""), TempInt2 - Switches * 2, TempInt - TempInt2 - 2)
                        OUTPUT.SelectedText = TempStr2
                    End If
                    OUTPUT.SelectionColor = Color.FromArgb(&H66)
                    TempInt2 = TempInt
                    Switches += 1
                ElseIf Mid(Txt, TempInt, 2) = "/C" Then
                    If TempInt2 <> 0 Then
                        TempStr2 = Mid(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Txt, "/b", ""), "/B", ""), "/g", ""), "/G", ""), "/m", ""), "/M", ""), "/w", ""), "/W", ""), "/y", ""), "/Y", ""), "/z", ""), "/Z", ""), "/c", ""), "/C", ""), "/r", ""), "/R", ""), TempInt2 - Switches * 2, TempInt - TempInt2 - 2)
                        OUTPUT.SelectedText = TempStr2
                    End If
                    OUTPUT.SelectionColor = Color.FromArgb(&HFFFF)
                    TempInt2 = TempInt
                    Switches += 1
                ElseIf Mid(Txt, TempInt, 2) = "/c" Then
                    If TempInt2 <> 0 Then
                        TempStr2 = Mid(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Txt, "/b", ""), "/B", ""), "/g", ""), "/G", ""), "/m", ""), "/M", ""), "/w", ""), "/W", ""), "/y", ""), "/Y", ""), "/z", ""), "/Z", ""), "/c", ""), "/C", ""), "/r", ""), "/R", ""), TempInt2 - Switches * 2, TempInt - TempInt2 - 2)
                        OUTPUT.SelectedText = TempStr2
                    End If
                    OUTPUT.SelectionColor = Color.FromArgb(&H6666)
                    TempInt2 = TempInt
                    Switches += 1
                ElseIf Mid(Txt, TempInt, 2) = "/M" Then
                    If TempInt2 <> 0 Then
                        TempStr2 = Mid(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Txt, "/b", ""), "/B", ""), "/g", ""), "/G", ""), "/m", ""), "/M", ""), "/w", ""), "/W", ""), "/y", ""), "/Y", ""), "/z", ""), "/Z", ""), "/c", ""), "/C", ""), "/r", ""), "/R", ""), TempInt2 - Switches * 2, TempInt - TempInt2 - 2)
                        OUTPUT.SelectedText = TempStr2
                    End If
                    OUTPUT.SelectionColor = Color.FromArgb(&HFF00FF)
                    TempInt2 = TempInt
                    Switches += 1
                ElseIf Mid(Txt, TempInt, 2) = "/m" Then
                    If TempInt2 <> 0 Then
                        TempStr2 = Mid(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Txt, "/b", ""), "/B", ""), "/g", ""), "/G", ""), "/m", ""), "/M", ""), "/w", ""), "/W", ""), "/y", ""), "/Y", ""), "/z", ""), "/Z", ""), "/c", ""), "/C", ""), "/r", ""), "/R", ""), TempInt2 - Switches * 2, TempInt - TempInt2 - 2)
                        OUTPUT.SelectedText = TempStr2
                    End If
                    OUTPUT.SelectionColor = Color.FromArgb(&H660066)
                    TempInt2 = TempInt
                    Switches += 1
                ElseIf Mid(Txt, TempInt, 2) = "/y" Then
                    If TempInt2 <> 0 Then
                        TempStr2 = Mid(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Txt, "/b", ""), "/B", ""), "/g", ""), "/G", ""), "/m", ""), "/M", ""), "/w", ""), "/W", ""), "/y", ""), "/Y", ""), "/z", ""), "/Z", ""), "/c", ""), "/C", ""), "/r", ""), "/R", ""), TempInt2 - Switches * 2, TempInt - TempInt2 - 2)
                        OUTPUT.SelectedText = TempStr2
                    End If
                    OUTPUT.SelectionColor = Color.FromArgb(&H666600)
                    TempInt2 = TempInt
                    Switches += 1
                ElseIf Mid(Txt, TempInt, 2) = "/Y" Then
                    If TempInt2 <> 0 Then
                        TempStr2 = Mid(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Txt, "/b", ""), "/B", ""), "/g", ""), "/G", ""), "/m", ""), "/M", ""), "/w", ""), "/W", ""), "/y", ""), "/Y", ""), "/z", ""), "/Z", ""), "/c", ""), "/C", ""), "/r", ""), "/R", ""), TempInt2 - Switches * 2, TempInt - TempInt2 - 2)
                        OUTPUT.SelectedText = TempStr2
                    End If
                    OUTPUT.SelectionColor = Color.FromArgb(&HFFFF00)
                    TempInt2 = TempInt
                    Switches += 1
                ElseIf Mid(Txt, TempInt, 2) = "/g" Then
                    If TempInt2 <> 0 Then
                        TempStr2 = Mid(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Txt, "/b", ""), "/B", ""), "/g", ""), "/G", ""), "/m", ""), "/M", ""), "/w", ""), "/W", ""), "/y", ""), "/Y", ""), "/z", ""), "/Z", ""), "/c", ""), "/C", ""), "/r", ""), "/R", ""), TempInt2 - Switches * 2, TempInt - TempInt2 - 2)
                        OUTPUT.SelectedText = TempStr2
                    End If
                    OUTPUT.SelectionColor = Color.FromArgb(&H6600)
                    TempInt2 = TempInt
                    Switches += 1
                ElseIf Mid(Txt, TempInt, 2) = "/G" Then
                    If TempInt2 <> 0 Then
                        TempStr2 = Mid(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Txt, "/b", ""), "/B", ""), "/g", ""), "/G", ""), "/m", ""), "/M", ""), "/w", ""), "/W", ""), "/y", ""), "/Y", ""), "/z", ""), "/Z", ""), "/c", ""), "/C", ""), "/r", ""), "/R", ""), TempInt2 - Switches * 2, TempInt - TempInt2 - 2)
                        OUTPUT.SelectedText = TempStr2
                    End If
                    OUTPUT.SelectionColor = Color.FromArgb(&HFF00)
                    TempInt2 = TempInt
                    Switches += 1
                ElseIf Mid(Txt, TempInt, 2) = "/w" Then
                    If TempInt2 <> 0 Then
                        TempStr2 = Mid(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Txt, "/b", ""), "/B", ""), "/g", ""), "/G", ""), "/m", ""), "/M", ""), "/w", ""), "/W", ""), "/y", ""), "/Y", ""), "/z", ""), "/Z", ""), "/c", ""), "/C", ""), "/r", ""), "/R", ""), TempInt2 - Switches * 2, TempInt - TempInt2 - 2)
                        OUTPUT.SelectedText = TempStr2
                    End If
                    OUTPUT.SelectionColor = Color.FromArgb(&H666666)
                    TempInt2 = TempInt
                    Switches += 1
                ElseIf Mid(Txt, TempInt, 2) = "/W" Then
                    If TempInt2 <> 0 Then
                        TempStr2 = Mid(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Txt, "/b", ""), "/B", ""), "/g", ""), "/G", ""), "/m", ""), "/M", ""), "/w", ""), "/W", ""), "/y", ""), "/Y", ""), "/z", ""), "/Z", ""), "/c", ""), "/C", ""), "/r", ""), "/R", ""), TempInt2 - Switches * 2, TempInt - TempInt2 - 2)
                        OUTPUT.SelectedText = TempStr2
                    End If
                    OUTPUT.SelectionColor = Color.FromArgb(&HAAAAAA)
                    TempInt2 = TempInt
                    Switches += 1
                ElseIf Mid(Txt, TempInt, 2) = "/z" Then
                    If TempInt2 <> 0 Then
                        TempStr2 = Mid(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Txt, "/b", ""), "/B", ""), "/g", ""), "/G", ""), "/m", ""), "/M", ""), "/w", ""), "/W", ""), "/y", ""), "/Y", ""), "/z", ""), "/Z", ""), "/c", ""), "/C", ""), "/r", ""), "/R", ""), TempInt2 - Switches * 2, TempInt - TempInt2 - 2)
                        OUTPUT.SelectedText = TempStr2
                    End If
                    OUTPUT.SelectionColor = Color.FromArgb(&H333333)
                    TempInt2 = TempInt
                    Switches += 1
                ElseIf Mid(Txt, TempInt, 2) = "/Z" Then
                    If TempInt2 <> 0 Then
                        TempStr2 = Mid(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Txt, "/b", ""), "/B", ""), "/g", ""), "/G", ""), "/m", ""), "/M", ""), "/w", ""), "/W", ""), "/y", ""), "/Y", ""), "/z", ""), "/Z", ""), "/c", ""), "/C", ""), "/r", ""), "/R", ""), TempInt2 - Switches * 2, TempInt - TempInt2 - 2)
                        OUTPUT.SelectedText = TempStr2
                    End If
                    OUTPUT.SelectionColor = Color.FromArgb(&HFFFFFF)
                    TempInt2 = TempInt
                    Switches += 1
                ElseIf Mid(Txt, TempInt, 2) = "/R" Then
                    If TempInt2 <> 0 Then
                        TempStr2 = Mid(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Txt, "/b", ""), "/B", ""), "/g", ""), "/G", ""), "/m", ""), "/M", ""), "/w", ""), "/W", ""), "/y", ""), "/Y", ""), "/z", ""), "/Z", ""), "/c", ""), "/C", ""), "/r", ""), "/R", ""), TempInt2 - Switches * 2, TempInt - TempInt2 - 2)
                        OUTPUT.SelectedText = TempStr2
                    End If
                    OUTPUT.SelectionColor = Color.FromArgb(&HFF0000)
                    TempInt2 = TempInt
                    Switches += 1
                ElseIf Mid(Txt, TempInt, 2) = "/r" Then
                    If TempInt2 <> 0 Then
                        TempStr2 = Mid(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Txt, "/b", ""), "/B", ""), "/g", ""), "/G", ""), "/m", ""), "/M", ""), "/w", ""), "/W", ""), "/y", ""), "/Y", ""), "/z", ""), "/Z", ""), "/c", ""), "/C", ""), "/r", ""), "/R", ""), TempInt2 - Switches * 2, TempInt - TempInt2 - 2)
                        OUTPUT.SelectedText = TempStr2
                    End If
                    OUTPUT.SelectionColor = Color.FromArgb(&H660000)
                    TempInt2 = TempInt
                    Switches += 1
                End If
            End If
        Next
        OUTPUT.SelectedText = Chr(13)
        SendMessage(OUTPUT.Handle, VertScrollBar, VertScrollBar_Btm, 0)
    End Sub
    Private Sub SilentCarriage(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles comments.KeyPress
        Dim keyascii As Integer = AscW(e.KeyChar)
        Dim isnumber As Boolean = Char.IsNumber(e.KeyChar)
        Dim isletter As Boolean = Char.IsLetter(e.KeyChar)
        If keyascii = 13 Then
            e.Handled = True
        End If
    End Sub

    Private Sub Ability_Affect1Define(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Ability_Affect1Type.SelectedIndexChanged
        If Ability_Affect1Type.SelectedIndex = 0 Then 'Damaging Type
            Ability_Affect1Damage.Enabled = True
            GB1.Enabled = True
            GB2.Enabled = False
            Ability_Affect1Healing.Enabled = False
            Ability_Affect1Modifier.Enabled = False
            Ability_Affect1Target.Enabled = True
            Ability_Affect1Timed.Enabled = True
            Ability_Affect1TimeAmount.Enabled = True
            Ability_Affect1Cure.Enabled = False
        ElseIf Ability_Affect1Type.SelectedIndex = 1 Then 'Healing Type
            Ability_Affect1Damage.Enabled = False
            GB1.Enabled = True
            GB2.Enabled = False
            Ability_Affect1Healing.Enabled = True
            Ability_Affect1Modifier.Enabled = False
            Ability_Affect1Target.Enabled = True
            Ability_Affect1Timed.Enabled = True
            Ability_Affect1TimeAmount.Enabled = True
            Ability_Affect1Cure.Enabled = False
        ElseIf Ability_Affect1Type.SelectedIndex = 2 Then 'Blind Type
            Ability_Affect1Damage.Enabled = False
            GB1.Enabled = False
            GB2.Enabled = False
            Ability_Affect1Healing.Enabled = False
            Ability_Affect1Modifier.Enabled = False
            Ability_Affect1Target.Enabled = True
            Ability_Affect1Timed.Enabled = True
            Ability_Affect1TimeAmount.Enabled = True
            Ability_Affect1Cure.Enabled = False
        ElseIf Ability_Affect1Type.SelectedIndex = 3 Then 'Silence Type
            Ability_Affect1Damage.Enabled = False
            GB1.Enabled = False
            GB2.Enabled = False
            Ability_Affect1Healing.Enabled = False
            Ability_Affect1Modifier.Enabled = False
            Ability_Affect1Target.Enabled = True
            Ability_Affect1Timed.Enabled = True
            Ability_Affect1TimeAmount.Enabled = True
            Ability_Affect1Cure.Enabled = False
        ElseIf Ability_Affect1Type.SelectedIndex = 4 Then 'Poison Type
            Ability_Affect1Damage.Enabled = True
            GB1.Enabled = True
            GB2.Enabled = False
            Ability_Affect1Healing.Enabled = False
            Ability_Affect1Modifier.Enabled = False
            Ability_Affect1Target.Enabled = True
            Ability_Affect1Timed.Enabled = True
            Ability_Affect1TimeAmount.Enabled = True
            Ability_Affect1Cure.Enabled = False
        ElseIf Ability_Affect1Type.SelectedIndex = 5 Then 'Disease Type
            Ability_Affect1Damage.Enabled = True
            GB1.Enabled = True
            GB2.Enabled = False
            Ability_Affect1Healing.Enabled = False
            Ability_Affect1Modifier.Enabled = False
            Ability_Affect1Target.Enabled = True
            Ability_Affect1Timed.Enabled = True
            Ability_Affect1TimeAmount.Enabled = True
            Ability_Affect1Cure.Enabled = False
        ElseIf Ability_Affect1Type.SelectedIndex = 6 Then 'Speed Type
            Ability_Affect1Damage.Enabled = False
            GB1.Enabled = False
            GB2.Enabled = False
            Ability_Affect1Healing.Enabled = False
            Ability_Affect1Modifier.Enabled = False
            Ability_Affect1Target.Enabled = True
            Ability_Affect1Timed.Enabled = True
            Ability_Affect1TimeAmount.Enabled = True
            Ability_Affect1Cure.Enabled = False
        ElseIf Ability_Affect1Type.SelectedIndex = 7 Then 'Summon Type
            Ability_Affect1Damage.Enabled = True
            GB1.Enabled = True
            GB2.Enabled = True
            Ability_Affect1Healing.Enabled = False
            Ability_Affect1Modifier.Enabled = False
            Ability_Affect1Target.Enabled = False
            Ability_Affect1Timed.Enabled = True
            Ability_Affect1TimeAmount.Enabled = True
            Ability_Affect1Cure.Enabled = False
        ElseIf Ability_Affect1Type.SelectedIndex = 8 Then 'Stats Modifier Type
            Ability_Affect1Damage.Enabled = False
            GB1.Enabled = False
            GB2.Enabled = False
            Ability_Affect1Healing.Enabled = False
            Ability_Affect1Modifier.Enabled = True
            Ability_Affect1Target.Enabled = True
            Ability_Affect1Timed.Enabled = True
            Ability_Affect1TimeAmount.Enabled = True
            Ability_Affect1Cure.Enabled = False
        ElseIf Ability_Affect1Type.SelectedIndex = 9 Then 'Aura Type
            Ability_Affect1Damage.Enabled = False
            GB1.Enabled = False
            GB2.Enabled = False
            Ability_Affect1Healing.Enabled = False
            Ability_Affect1Modifier.Enabled = False
            Ability_Affect1Target.Enabled = True
            Ability_Affect1Timed.Enabled = True
            Ability_Affect1TimeAmount.Enabled = True
            Ability_Affect1Cure.Enabled = False
        ElseIf Ability_Affect1Type.SelectedIndex = 10 Then 'Fear Type
            Ability_Affect1Damage.Enabled = False
            GB1.Enabled = False
            GB2.Enabled = False
            Ability_Affect1Healing.Enabled = False
            Ability_Affect1Modifier.Enabled = False
            Ability_Affect1Target.Enabled = True
            Ability_Affect1Timed.Enabled = True
            Ability_Affect1TimeAmount.Enabled = True
            Ability_Affect1Cure.Enabled = False
        ElseIf Ability_Affect1Type.SelectedIndex = 11 Then 'Cripple Type
            Ability_Affect1Damage.Enabled = False
            GB1.Enabled = False
            GB2.Enabled = False
            Ability_Affect1Healing.Enabled = False
            Ability_Affect1Modifier.Enabled = False
            Ability_Affect1Target.Enabled = True
            Ability_Affect1Timed.Enabled = True
            Ability_Affect1TimeAmount.Enabled = True
            Ability_Affect1Cure.Enabled = False
        ElseIf Ability_Affect1Type.SelectedIndex = 12 Then 'Stun
            Ability_Affect1Damage.Enabled = False
            GB1.Enabled = False
            GB2.Enabled = False
            Ability_Affect1Healing.Enabled = False
            Ability_Affect1Modifier.Enabled = False
            Ability_Affect1Target.Enabled = True
            Ability_Affect1Timed.Enabled = True
            Ability_Affect1TimeAmount.Enabled = True
            Ability_Affect1Cure.Enabled = False
        ElseIf Ability_Affect1Type.SelectedIndex = 13 Then 'Cure
            Ability_Affect1Damage.Enabled = False
            GB1.Enabled = False
            GB2.Enabled = False
            Ability_Affect1Healing.Enabled = False
            Ability_Affect1Modifier.Enabled = False
            Ability_Affect1Target.Enabled = True
            Ability_Affect1Timed.Enabled = False
            Ability_Affect1TimeAmount.Enabled = False
            Ability_Affect1Cure.Enabled = True
        End If
    End Sub

    Private Sub Affect1RBChange(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles A1RB1.CheckedChanged, A1RB5.CheckedChanged, A1RB4.CheckedChanged, A1RB3.CheckedChanged, A1RB2.CheckedChanged, A1RB7.CheckedChanged, A1RB6.CheckedChanged, A2RB1.CheckedChanged
        If A1RB1.Checked = True Then
            A1DB1.Enabled = True
            A1DB2.Enabled = False
            A1DB3.Enabled = False
            A1DB4a.Enabled = False
            A1DB4b.Enabled = False
            A1DB4c.Enabled = False
            A1DB4e.Enabled = False
            A1DB4d.Enabled = False
            A1DB5.Enabled = False
            A1DB6.Enabled = False
            A1DB7.Enabled = False
        ElseIf A1RB2.Checked = True Then
            A1DB1.Enabled = False
            A1DB2.Enabled = True
            A1DB3.Enabled = False
            A1DB4a.Enabled = False
            A1DB4b.Enabled = False
            A1DB4c.Enabled = False
            A1DB4e.Enabled = False
            A1DB4d.Enabled = False
            A1DB5.Enabled = False
            A1DB6.Enabled = False
            A1DB7.Enabled = False
        ElseIf A1RB3.Checked = True Then
            A1DB1.Enabled = False
            A1DB2.Enabled = False
            A1DB3.Enabled = True
            A1DB4a.Enabled = False
            A1DB4b.Enabled = False
            A1DB4c.Enabled = False
            A1DB4e.Enabled = False
            A1DB4d.Enabled = False
            A1DB5.Enabled = False
            A1DB6.Enabled = False
            A1DB7.Enabled = False
        ElseIf A1RB4.Checked = True Then
            A1DB1.Enabled = False
            A1DB2.Enabled = False
            A1DB3.Enabled = False
            A1DB4a.Enabled = True
            A1DB4b.Enabled = True
            A1DB4c.Enabled = True
            A1DB4e.Enabled = True
            A1DB4d.Enabled = True
            A1DB5.Enabled = False
            A1DB6.Enabled = False
            A1DB7.Enabled = False
        ElseIf A1RB5.Checked = True Then
            A1DB1.Enabled = False
            A1DB2.Enabled = False
            A1DB3.Enabled = False
            A1DB4a.Enabled = False
            A1DB4b.Enabled = False
            A1DB4c.Enabled = False
            A1DB4e.Enabled = False
            A1DB4d.Enabled = False
            A1DB5.Enabled = True
            A1DB6.Enabled = False
            A1DB7.Enabled = False
        ElseIf A1RB6.Checked = True Then
            A1DB1.Enabled = False
            A1DB2.Enabled = False
            A1DB3.Enabled = False
            A1DB4a.Enabled = False
            A1DB4b.Enabled = False
            A1DB4c.Enabled = False
            A1DB4e.Enabled = False
            A1DB4d.Enabled = False
            A1DB5.Enabled = False
            A1DB6.Enabled = True
            A1DB7.Enabled = False
        ElseIf A1RB7.Checked = True Then
            A1DB1.Enabled = False
            A1DB2.Enabled = False
            A1DB3.Enabled = False
            A1DB4a.Enabled = False
            A1DB4b.Enabled = False
            A1DB4c.Enabled = False
            A1DB4e.Enabled = False
            A1DB4d.Enabled = False
            A1DB5.Enabled = False
            A1DB6.Enabled = False
            A1DB7.Enabled = True
        End If
    End Sub
    Private Sub Affect2RBChange(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles A2RB1.CheckedChanged, A2RB5.CheckedChanged, A2RB4.CheckedChanged, A2RB3.CheckedChanged, A2RB2.CheckedChanged, A2RB7.CheckedChanged, A2RB6.CheckedChanged, A2RB1.CheckedChanged
        If A2RB1.Checked = True Then
            A2DB1.Enabled = True
            A2DB2.Enabled = False
            A2DB3.Enabled = False
            A2DB4a.Enabled = False
            A2DB4b.Enabled = False
            A2DB4c.Enabled = False
            A2DB4e.Enabled = False
            A2DB4d.Enabled = False
            A2DB5.Enabled = False
            A2DB6.Enabled = False
            A2DB7.Enabled = False
        ElseIf A2RB2.Checked = True Then
            A2DB1.Enabled = False
            A2DB2.Enabled = True
            A2DB3.Enabled = False
            A2DB4a.Enabled = False
            A2DB4b.Enabled = False
            A2DB4c.Enabled = False
            A2DB4e.Enabled = False
            A2DB4d.Enabled = False
            A2DB5.Enabled = False
            A2DB6.Enabled = False
            A2DB7.Enabled = False
        ElseIf A2RB3.Checked = True Then
            A2DB1.Enabled = False
            A2DB2.Enabled = False
            A2DB3.Enabled = True
            A2DB4a.Enabled = False
            A2DB4b.Enabled = False
            A2DB4c.Enabled = False
            A2DB4e.Enabled = False
            A2DB4d.Enabled = False
            A2DB5.Enabled = False
            A2DB6.Enabled = False
            A2DB7.Enabled = False
        ElseIf A2RB4.Checked = True Then
            A2DB1.Enabled = False
            A2DB2.Enabled = False
            A2DB3.Enabled = False
            A2DB4a.Enabled = True
            A2DB4b.Enabled = True
            A2DB4c.Enabled = True
            A2DB4e.Enabled = True
            A2DB4d.Enabled = True
            A2DB5.Enabled = False
            A2DB6.Enabled = False
            A2DB7.Enabled = False
        ElseIf A2RB5.Checked = True Then
            A2DB1.Enabled = False
            A2DB2.Enabled = False
            A2DB3.Enabled = False
            A2DB4a.Enabled = False
            A2DB4b.Enabled = False
            A2DB4c.Enabled = False
            A2DB4e.Enabled = False
            A2DB4d.Enabled = False
            A2DB5.Enabled = True
            A2DB6.Enabled = False
            A2DB7.Enabled = False
        ElseIf A2RB6.Checked = True Then
            A2DB1.Enabled = False
            A2DB2.Enabled = False
            A2DB3.Enabled = False
            A2DB4a.Enabled = False
            A2DB4b.Enabled = False
            A2DB4c.Enabled = False
            A2DB4e.Enabled = False
            A2DB4d.Enabled = False
            A2DB5.Enabled = False
            A2DB6.Enabled = True
            A2DB7.Enabled = False
        ElseIf A2RB7.Checked = True Then
            A2DB1.Enabled = False
            A2DB2.Enabled = False
            A2DB3.Enabled = False
            A2DB4a.Enabled = False
            A2DB4b.Enabled = False
            A2DB4c.Enabled = False
            A2DB4e.Enabled = False
            A2DB4d.Enabled = False
            A2DB5.Enabled = False
            A2DB6.Enabled = False
            A2DB7.Enabled = True
        End If
    End Sub
    Private Sub Affect3RBChange(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles A3RB1.CheckedChanged, A3RB5.CheckedChanged, A3RB4.CheckedChanged, A3RB3.CheckedChanged, A3RB2.CheckedChanged, A3RB7.CheckedChanged, A3RB6.CheckedChanged, A2RB1.CheckedChanged
        If A3RB1.Checked = True Then
            A3DB1.Enabled = True
            A3DB2.Enabled = False
            A3DB3.Enabled = False
            A3DB4a.Enabled = False
            A3DB4b.Enabled = False
            A3DB4c.Enabled = False
            A3DB4e.Enabled = False
            A3DB4d.Enabled = False
            A3DB5.Enabled = False
            A3DB6.Enabled = False
            A3DB7.Enabled = False
        ElseIf A3RB2.Checked = True Then
            A3DB1.Enabled = False
            A3DB2.Enabled = True
            A3DB3.Enabled = False
            A3DB4a.Enabled = False
            A3DB4b.Enabled = False
            A3DB4c.Enabled = False
            A3DB4e.Enabled = False
            A3DB4d.Enabled = False
            A3DB5.Enabled = False
            A3DB6.Enabled = False
            A3DB7.Enabled = False
        ElseIf A3RB3.Checked = True Then
            A3DB1.Enabled = False
            A3DB2.Enabled = False
            A3DB3.Enabled = True
            A3DB4a.Enabled = False
            A3DB4b.Enabled = False
            A3DB4c.Enabled = False
            A3DB4e.Enabled = False
            A3DB4d.Enabled = False
            A3DB5.Enabled = False
            A3DB6.Enabled = False
            A3DB7.Enabled = False
        ElseIf A3RB4.Checked = True Then
            A3DB1.Enabled = False
            A3DB2.Enabled = False
            A3DB3.Enabled = False
            A3DB4a.Enabled = True
            A3DB4b.Enabled = True
            A3DB4c.Enabled = True
            A3DB4e.Enabled = True
            A3DB4d.Enabled = True
            A3DB5.Enabled = False
            A3DB6.Enabled = False
            A3DB7.Enabled = False
        ElseIf A3RB5.Checked = True Then
            A3DB1.Enabled = False
            A3DB2.Enabled = False
            A3DB3.Enabled = False
            A3DB4a.Enabled = False
            A3DB4b.Enabled = False
            A3DB4c.Enabled = False
            A3DB4e.Enabled = False
            A3DB4d.Enabled = False
            A3DB5.Enabled = True
            A3DB6.Enabled = False
            A3DB7.Enabled = False
        ElseIf A3RB6.Checked = True Then
            A3DB1.Enabled = False
            A3DB2.Enabled = False
            A3DB3.Enabled = False
            A3DB4a.Enabled = False
            A3DB4b.Enabled = False
            A3DB4c.Enabled = False
            A3DB4e.Enabled = False
            A3DB4d.Enabled = False
            A3DB5.Enabled = False
            A3DB6.Enabled = True
            A3DB7.Enabled = False
        ElseIf A3RB7.Checked = True Then
            A3DB1.Enabled = False
            A3DB2.Enabled = False
            A3DB3.Enabled = False
            A3DB4a.Enabled = False
            A3DB4b.Enabled = False
            A3DB4c.Enabled = False
            A3DB4e.Enabled = False
            A3DB4d.Enabled = False
            A3DB5.Enabled = False
            A3DB6.Enabled = False
            A3DB7.Enabled = True
        End If
    End Sub
    Private Sub Affect4RBChange(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles A4RB1.CheckedChanged, A4RB5.CheckedChanged, A4RB4.CheckedChanged, A4RB3.CheckedChanged, A4RB2.CheckedChanged, A4RB7.CheckedChanged, A4RB6.CheckedChanged, A2RB1.CheckedChanged
        If A4RB1.Checked = True Then
            A4DB1.Enabled = True
            A4DB2.Enabled = False
            A4DB3.Enabled = False
            A4DB4a.Enabled = False
            A4DB4b.Enabled = False
            A4DB4c.Enabled = False
            A4DB4e.Enabled = False
            A4DB4d.Enabled = False
            A4DB5.Enabled = False
            A4DB6.Enabled = False
            A4DB7.Enabled = False
        ElseIf A4RB2.Checked = True Then
            A4DB1.Enabled = False
            A4DB2.Enabled = True
            A4DB3.Enabled = False
            A4DB4a.Enabled = False
            A4DB4b.Enabled = False
            A4DB4c.Enabled = False
            A4DB4e.Enabled = False
            A4DB4d.Enabled = False
            A4DB5.Enabled = False
            A4DB6.Enabled = False
            A4DB7.Enabled = False
        ElseIf A4RB3.Checked = True Then
            A4DB1.Enabled = False
            A4DB2.Enabled = False
            A4DB3.Enabled = True
            A4DB4a.Enabled = False
            A4DB4b.Enabled = False
            A4DB4c.Enabled = False
            A4DB4e.Enabled = False
            A4DB4d.Enabled = False
            A4DB5.Enabled = False
            A4DB6.Enabled = False
            A4DB7.Enabled = False
        ElseIf A4RB4.Checked = True Then
            A4DB1.Enabled = False
            A4DB2.Enabled = False
            A4DB3.Enabled = False
            A4DB4a.Enabled = True
            A4DB4b.Enabled = True
            A4DB4c.Enabled = True
            A4DB4e.Enabled = True
            A4DB4d.Enabled = True
            A4DB5.Enabled = False
            A4DB6.Enabled = False
            A4DB7.Enabled = False
        ElseIf A4RB5.Checked = True Then
            A4DB1.Enabled = False
            A4DB2.Enabled = False
            A4DB3.Enabled = False
            A4DB4a.Enabled = False
            A4DB4b.Enabled = False
            A4DB4c.Enabled = False
            A4DB4e.Enabled = False
            A4DB4d.Enabled = False
            A4DB5.Enabled = True
            A4DB6.Enabled = False
            A4DB7.Enabled = False
        ElseIf A4RB6.Checked = True Then
            A4DB1.Enabled = False
            A4DB2.Enabled = False
            A4DB3.Enabled = False
            A4DB4a.Enabled = False
            A4DB4b.Enabled = False
            A4DB4c.Enabled = False
            A4DB4e.Enabled = False
            A4DB4d.Enabled = False
            A4DB5.Enabled = False
            A4DB6.Enabled = True
            A4DB7.Enabled = False
        ElseIf A4RB7.Checked = True Then
            A4DB1.Enabled = False
            A4DB2.Enabled = False
            A4DB3.Enabled = False
            A4DB4a.Enabled = False
            A4DB4b.Enabled = False
            A4DB4c.Enabled = False
            A4DB4e.Enabled = False
            A4DB4d.Enabled = False
            A4DB5.Enabled = False
            A4DB6.Enabled = False
            A4DB7.Enabled = True
        End If
    End Sub


    Private Sub BeginAbilityEditor(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        SND("/GTemplate loaded.")
        SND("/g(Ready for editing)")
    End Sub

    Private Sub findabilitylist(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LoadAbility.DropDown
        LoadAbility.Items.Clear()
        Dim int2 As Integer
        Dim int3 As Integer
        Dim int4 As Integer
        Dim CurNum As Integer = 1
        Dim str1 As String = Replace(Str(CurNum), " ", "")
        AbilityData = GetFileContents(Debugger.DirAbilities)
        Dim astr As String = ""
        Dim aint As Integer
        Dim mshort As String = ""
        For aint = InStr(AbilityData, "TOTAL#") To Len(AbilityData) Step 1
            If Mid(AbilityData, aint, 1) = "(" Then
                astr = LTrim(Str(Val(Mid(AbilityData, InStr(AbilityData, "TOTAL#") + 6, aint - InStr(AbilityData, "TOTAL#") - 6))))
                AbilityData = Replace(AbilityData, Mid(AbilityData, InStr(AbilityData, "TOTAL#"), 8 + Len(astr) * 2), "TOTAL#" + astr + "(" + astr + ")")
                Exit For
            End If
        Next
        For int2 = 1 To Val(astr) Step 1
            If InStr(AbilityData, "VIRID#" + LTrim(Str(int2)) + "(") > 0 Then
                For int3 = InStr(AbilityData, "VIRID#" + LTrim(Str(int2)) + "(") To Len(AbilityData) Step 1
                    If Mid(AbilityData, int3, 1) = ")" Then
                        For int4 = InStr(AbilityData, "ANAME#" + LTrim(Str(int2)) + "(") To Len(AbilityData) Step 1
                            If Mid(AbilityData, int4, 1) = ")" Then
                                mshort = Mid(AbilityData, InStr(AbilityData, "ANAME#" + LTrim(Str(int2)) + "(") + 7 + Len(LTrim(Str(int2))), int4 - 14 - Len(LTrim(Str(int2))) * 2 - InStr(AbilityData, "ANAME#" + LTrim(Str(int2))) + 7 + Len(LTrim(Str(int2))))
                                Exit For
                            End If
                        Next
                        LoadAbility.Items.Add(LTrim(Str(int2)) + ". " + mshort)
                        Exit For
                    End If
                Next
            End If
        Next
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        AbilityData = GetFileContents(Debugger.DirAbilities)
        Dim errornum As Short = 0
        Dim aint As Short
        Dim tAbilityData As String = AbilityData
        Dim overwrite As Boolean = False
        Dim astr As String = ""
        If InStr(AbilityData, "TOTAL#") = 0 Then AbilityData = "TOTAL#0(0)"
        For aint = InStr(AbilityData, "TOTAL#") To Len(AbilityData) Step 1
            If Mid(AbilityData, aint, 1) = "(" Then
                astr = LTrim(Str(Val(Mid(AbilityData, InStr(AbilityData, "TOTAL#") + 6, aint - InStr(AbilityData, "TOTAL#") - 6)) + 1))
                Exit For
            End If
        Next
        SND("/GAttempting to create VIRID number " + VIRID.Text + "...")
        If Val(VIRID.Text) < Val(astr) Then
            SND("/GOverwriting VIRID number " + VIRID.Text + "...")
            overwrite = True
            AbilityData = ""
        ElseIf Val(VIRID.Text) = (Val(astr)) Then
            SND("/GAllocating VIRID number " + VIRID.Text + " was a success.")
            AbilityData = Replace(AbilityData, Mid(AbilityData, InStr(AbilityData, "TOTAL#"), 8 + Len(astr) * 2), "TOTAL#" + astr + "(" + astr + ")" + Chr(13))
        ElseIf Val(VIRID.Text) > Val(astr) Then
            SND("/RAllocating VIRID number " + VIRID.Text + " Failed. Out of Bounds.")
            SND("/rChange VIRID to " + astr + " to create a new one or lower to overwrite one.")
            errornum += 1
        End If
        SND("/GReserved VNUM: /Z" + VIRID.Text)
        SND("/wVIRID/z#" + VIRID.Text + "/W(/c" + VIRID.Text + "/W)")
        If VIRID.Text = "1" Then
            AbilityData += Mid(LTrim(Str(Val(astr) - 1)), Len(LTrim(Str(Val(astr) - 1))), 1) + ")" + Chr(13) + Chr(13) + "VIRID#" + VIRID.Text + "(" + VIRID.Text + ")"
        Else
            AbilityData += Chr(13) + Chr(13) + "VIRID#" + VIRID.Text + "(" + VIRID.Text + ")"
        End If
        astr = VIRID.Text
        SND("/wSHORT/z#" + astr + "/W(/c" + Ability_Short.Text + "/W)")
        AbilityData += Chr(13) + "SHORT#" + astr + "(" + Ability_Short.Text + ")"
        SND("/wANAME/z#" + astr + "/W(/c" + Ability_Name.Text + "/W)")
        AbilityData += Chr(13) + "ANAME#" + astr + "(" + Ability_Name.Text + ")"
        SND("/wREQUI/z#" + astr + "/W(/c" + Mid(Ability_ReqClass.Text, 1, 2) + "," + LTrim(RTrim(Ability_ReqLevel.Text)) + "/W)")
        AbilityData += Chr(13) + "REQUI#" + astr + "(" + Mid(Ability_ReqClass.Text, 1, 2) + "," + LTrim(RTrim(Ability_ReqLevel.Text)) + ")"
        SND("/wATIME/z#" + astr + "/W(/c" + Ability_Time.Text + "/W)")
        AbilityData += Chr(13) + "ATIME#" + astr + "(" + Ability_Time.Text + ")"
        If RB1.Checked = True Then
            SND("/wACOST/z#" + astr + "/W(/c" + AC1.Text + "HP/W)")
            AbilityData += Chr(13) + "ACOST#" + astr + "(" + AC1.Text + "HP)"
        ElseIf RB2.Checked = True Then
            SND("/wACOST/z#" + astr + "/W(/c" + AC2.Text + "WP/W)")
            AbilityData += Chr(13) + "ACOST#" + astr + "(" + AC1.Text + "WP)"
        ElseIf RB3.Checked = True Then
            SND("/wACOST/z#" + astr + "/W(/c" + AC3.Text + "SP/W)")
            AbilityData += Chr(13) + "ACOST#" + astr + "(" + AC1.Text + "SP)"
        ElseIf RB5.Checked = True Then
            If Mid(AC5b.Text, 1, 1) = "0" Then
                SND("/wACOST/z#" + astr + "/W(/c" + AC5a.Text + "HP/W)")
                AbilityData += Chr(13) + "ACOST#" + astr + "(" + AC5a.Text + "HP)"
            ElseIf Mid(AC5b.Text, 1, 1) = "1" Then
                SND("/wACOST/z#" + astr + "/W(/c" + AC5a.Text + "WP/W)")
                AbilityData += Chr(13) + "ACOST#" + astr + "(" + AC5a.Text + "WP)"
            ElseIf Mid(AC5b.Text, 1, 1) = "2" Then
                SND("/wACOST/z#" + astr + "/W(/c" + AC5a.Text + "SP/W)")
                AbilityData += Chr(13) + "ACOST#" + astr + "(" + AC5a.Text + "SP)"
            End If
        End If
        If Exhaustion.Checked = True Then
            SND("/wEXHAU/z#" + astr + "/W(/c1/W)")
            AbilityData += Chr(13) + "EXHAU#" + astr + "(1)"
        Else
            SND("/wEXHAU/z#" + astr + "/W(/c0/W)")
            AbilityData += Chr(13) + "EXHAU#" + astr + "(0)"
        End If
        If OBattle.Checked = True Then
            SND("/wBATOU/z#" + astr + "/W(/c1/W)")
            AbilityData += Chr(13) + "BATOU#" + astr + "(1)"
        Else
            SND("/wBATOU/z#" + astr + "/W(/c0/W)")
            AbilityData += Chr(13) + "BATOU#" + astr + "(0)"
        End If
        If IBattle.Checked = True Then
            SND("/wBATIN/z#" + astr + "/W(/c1/W)")
            AbilityData += Chr(13) + "BATIN#" + astr + "(1)"
        Else
            SND("/wBATIN/z#" + astr + "/W(/c0/W)")
            AbilityData += Chr(13) + "BATIN#" + astr + "(0)"
        End If
        Dim AffectString As String
        If Ability_Affect1.Checked = True Then
            SND("/wAFNUM/z#" + astr + "/W(/c1/W)")
            AbilityData += Chr(13) + "AFNUM#" + astr + "(1)"
            AffectString = Mid(Ability_Affect1Type.Text, 1, 2) + ","
            If Ability_Affect1Damage.Enabled = True Then AffectString += Mid(Ability_Affect1Damage.Text, 1, 2) + ","
            If GB1.Enabled = True Then
                If A1RB1.Checked = True Then
                    AffectString += A1DB1.Text + "HP,"
                ElseIf A1RB2.Checked = True Then
                    AffectString += A1DB2.Text + "WP,"
                ElseIf A1RB3.Checked = True Then
                    AffectString += A1DB3.Text + "SP,"
                ElseIf A1RB4.Checked = True Then
                    AffectString += A1DB4a.Text + A1DB4b.Text + "+" + A1DB4d.Text + "." + Mid(A1DB4c.Text, 1, 1) + Mid(A1DB4e.Text, 1, 2) + ","
                ElseIf A1RB5.Checked = True Then
                    AffectString += A1DB5.Text + "HP,"
                ElseIf A1RB6.Checked = True Then
                    AffectString += A1DB6.Text + "WP,"
                ElseIf A1RB7.Checked = True Then
                    AffectString += A1DB7.Text + "SP,"
                End If
            End If
            If Ability_Affect1Healing.Enabled = True Then AffectString += Mid(Ability_Affect1Healing.Text, 1, 1) + ","
            If Ability_Affect1Target.Enabled = True Then AffectString += Mid(Ability_Affect1Target.Text, 1, 1) + ","
            If Ability_Affect1Modifier.Enabled = True Then AffectString += Mid(Ability_Affect1Modifier.Text, 1, 2) + ","
            If Ability_Affect1Cure.Enabled = True Then AffectString += Mid(Ability_Affect1Cure.Text, 1, 1) + ","
            If Ability_Affect1Timed.Enabled = True Then AffectString += Mid(Ability_Affect1Timed.Text, 1, 1) + ","
            If Ability_Affect1TimeAmount.Enabled = True Then AffectString += LTrim(Ability_Affect1TimeAmount.Text) + ","
            If GB2.Enabled = True Then AffectString += LTrim(Ability_Affect1SummonHP.Text) + "." + LTrim(Ability_Affect1SummonWP.Text) + "." + LTrim(Ability_Affect1SummonSP.Text) + ","
            AffectString = Mid(AffectString, 1, Len(AffectString) - 1)
            SND("/wAFFE1/z#" + astr + "/W(/c" + AffectString + "/W)")
            AbilityData += Chr(13) + "AFFE1#" + astr + "(" + AffectString + ")"
        ElseIf Ability_Affect2.Checked = True Then
            SND("/wAFNUM/z#" + astr + "/W(/c2/W)")
            AbilityData += Chr(13) + "AFNUM#" + astr + "(2)"
            AffectString = Mid(Ability_Affect1Type.Text, 1, 2) + ","
            If Ability_Affect1Damage.Enabled = True Then AffectString += Mid(Ability_Affect1Damage.Text, 1, 2) + ","
            If GB1.Enabled = True Then
                If A1RB1.Checked = True Then
                    AffectString += A1DB1.Text + "HP,"
                ElseIf A1RB2.Checked = True Then
                    AffectString += A1DB2.Text + "WP,"
                ElseIf A1RB3.Checked = True Then
                    AffectString += A1DB3.Text + "SP,"
                ElseIf A1RB4.Checked = True Then
                    AffectString += A1DB4a.Text + A1DB4b.Text + "+" + A1DB4d.Text + "." + Mid(A1DB4c.Text, 1, 1) + Mid(A1DB4e.Text, 1, 2) + ","
                ElseIf A1RB5.Checked = True Then
                    AffectString += A1DB5.Text + "HP,"
                ElseIf A1RB6.Checked = True Then
                    AffectString += A1DB6.Text + "WP,"
                ElseIf A1RB7.Checked = True Then
                    AffectString += A1DB7.Text + "SP,"
                End If
            End If
            If Ability_Affect1Healing.Enabled = True Then AffectString += Mid(Ability_Affect1Healing.Text, 1, 1) + ","
            If Ability_Affect1Target.Enabled = True Then AffectString += Mid(Ability_Affect1Target.Text, 1, 1) + ","
            If Ability_Affect1Modifier.Enabled = True Then AffectString += Mid(Ability_Affect1Modifier.Text, 1, 2) + ","
            If Ability_Affect1Cure.Enabled = True Then AffectString += Mid(Ability_Affect1Cure.Text, 1, 1) + ","
            If Ability_Affect1Timed.Enabled = True Then AffectString += Mid(Ability_Affect1Timed.Text, 1, 1) + ","
            If Ability_Affect1TimeAmount.Enabled = True Then AffectString += LTrim(Ability_Affect1TimeAmount.Text) + ","
            If GB2.Enabled = True Then AffectString += LTrim(Ability_Affect1SummonHP.Text) + "." + LTrim(Ability_Affect1SummonWP.Text) + "." + LTrim(Ability_Affect1SummonSP.Text) + ","
            AffectString = Mid(AffectString, 1, Len(AffectString) - 1)
            SND("/wAFFE1/z#" + astr + "/W(/c" + AffectString + "/W)")
            AbilityData += Chr(13) + "AFFE1#" + astr + "(" + AffectString + ")"
            AffectString = Mid(Ability_Affect2Type.Text, 1, 2) + ","
            If Ability_Affect2Damage.Enabled = True Then AffectString += Mid(Ability_Affect2Damage.Text, 1, 2) + ","
            If GB3.Enabled = True Then
                If A2RB1.Checked = True Then
                    AffectString += A2DB1.Text + "HP,"
                ElseIf A2RB2.Checked = True Then
                    AffectString += A2DB2.Text + "WP,"
                ElseIf A2RB3.Checked = True Then
                    AffectString += A2DB3.Text + "SP,"
                ElseIf A2RB4.Checked = True Then
                    AffectString += A2DB4a.Text + A2DB4b.Text + "+" + A2DB4d.Text + "." + Mid(A2DB4c.Text, 1, 1) + Mid(A2DB4e.Text, 1, 2) + ","
                ElseIf A2RB5.Checked = True Then
                    AffectString += A2DB5.Text + "HP,"
                ElseIf A2RB6.Checked = True Then
                    AffectString += A2DB6.Text + "WP,"
                ElseIf A2RB7.Checked = True Then
                    AffectString += A2DB7.Text + "SP,"
                End If
            End If
            If Ability_Affect2Healing.Enabled = True Then AffectString += Mid(Ability_Affect2Healing.Text, 1, 1) + ","
            If Ability_Affect2Target.Enabled = True Then AffectString += Mid(Ability_Affect2Target.Text, 1, 1) + ","
            If Ability_Affect2Modifier.Enabled = True Then AffectString += Mid(Ability_Affect2Modifier.Text, 1, 2) + ","
            If Ability_Affect2Cure.Enabled = True Then AffectString += Mid(Ability_Affect2Cure.Text, 1, 1) + ","
            If Ability_Affect2Timed.Enabled = True Then AffectString += Mid(Ability_Affect2Timed.Text, 1, 1) + ","
            If Ability_Affect2TimeAmount.Enabled = True Then AffectString += LTrim(Ability_Affect2TimeAmount.Text) + ","
            If GB4.Enabled = True Then AffectString += LTrim(Ability_Affect2SummonHP.Text) + "." + LTrim(Ability_Affect2SummonWP.Text) + "." + LTrim(Ability_Affect2SummonSP.Text) + ","
            AffectString = Mid(AffectString, 1, Len(AffectString) - 1)
            SND("/wAFFE2/z#" + astr + "/W(/c" + AffectString + "/W)")
            AbilityData += Chr(13) + "AFFE2#" + astr + "(" + AffectString + ")"
        ElseIf Ability_Affect3.Checked = True Then
            SND("/wAFNUM/z#" + astr + "/W(/c3/W)")
            AbilityData += Chr(13) + "AFNUM#" + astr + "(3)"
            AffectString = Mid(Ability_Affect1Type.Text, 1, 2) + ","
            If Ability_Affect1Damage.Enabled = True Then AffectString += Mid(Ability_Affect1Damage.Text, 1, 2) + ","
            If GB1.Enabled = True Then
                If A1RB1.Checked = True Then
                    AffectString += A1DB1.Text + "HP,"
                ElseIf A1RB2.Checked = True Then
                    AffectString += A1DB2.Text + "WP,"
                ElseIf A1RB3.Checked = True Then
                    AffectString += A1DB3.Text + "SP,"
                ElseIf A1RB4.Checked = True Then
                    AffectString += A1DB4a.Text + A1DB4b.Text + "+" + A1DB4d.Text + "." + Mid(A1DB4c.Text, 1, 1) + Mid(A1DB4e.Text, 1, 2) + ","
                ElseIf A1RB5.Checked = True Then
                    AffectString += A1DB5.Text + "HP,"
                ElseIf A1RB6.Checked = True Then
                    AffectString += A1DB6.Text + "WP,"
                ElseIf A1RB7.Checked = True Then
                    AffectString += A1DB7.Text + "SP,"
                End If
            End If
            If Ability_Affect1Healing.Enabled = True Then AffectString += Mid(Ability_Affect1Healing.Text, 1, 1) + ","
            If Ability_Affect1Target.Enabled = True Then AffectString += Mid(Ability_Affect1Target.Text, 1, 1) + ","
            If Ability_Affect1Modifier.Enabled = True Then AffectString += Mid(Ability_Affect1Modifier.Text, 1, 2) + ","
            If Ability_Affect1Cure.Enabled = True Then AffectString += Mid(Ability_Affect1Cure.Text, 1, 1) + ","
            If Ability_Affect1Timed.Enabled = True Then AffectString += Mid(Ability_Affect1Timed.Text, 1, 1) + ","
            If Ability_Affect1TimeAmount.Enabled = True Then AffectString += LTrim(Ability_Affect1TimeAmount.Text) + ","
            If GB2.Enabled = True Then AffectString += LTrim(Ability_Affect1SummonHP.Text) + "." + LTrim(Ability_Affect1SummonWP.Text) + "." + LTrim(Ability_Affect1SummonSP.Text) + ","
            AffectString = Mid(AffectString, 1, Len(AffectString) - 1)
            SND("/wAFFE1/z#" + astr + "/W(/c" + AffectString + "/W)")
            AbilityData += Chr(13) + "AFFE1#" + astr + "(" + AffectString + ")"
            AffectString = Mid(Ability_Affect2Type.Text, 1, 2) + ","
            If Ability_Affect2Damage.Enabled = True Then AffectString += Mid(Ability_Affect2Damage.Text, 1, 2) + ","
            If GB3.Enabled = True Then
                If A2RB1.Checked = True Then
                    AffectString += A2DB1.Text + "HP,"
                ElseIf A2RB2.Checked = True Then
                    AffectString += A2DB2.Text + "WP,"
                ElseIf A2RB3.Checked = True Then
                    AffectString += A2DB3.Text + "SP,"
                ElseIf A2RB4.Checked = True Then
                    AffectString += A2DB4a.Text + A2DB4b.Text + "+" + A2DB4d.Text + "." + Mid(A2DB4c.Text, 1, 1) + Mid(A2DB4e.Text, 1, 2) + ","
                ElseIf A2RB5.Checked = True Then
                    AffectString += A2DB5.Text + "HP,"
                ElseIf A2RB6.Checked = True Then
                    AffectString += A2DB6.Text + "WP,"
                ElseIf A2RB7.Checked = True Then
                    AffectString += A2DB7.Text + "SP,"
                End If
            End If
            If Ability_Affect2Healing.Enabled = True Then AffectString += Mid(Ability_Affect2Healing.Text, 1, 1) + ","
            If Ability_Affect2Target.Enabled = True Then AffectString += Mid(Ability_Affect2Target.Text, 1, 1) + ","
            If Ability_Affect2Modifier.Enabled = True Then AffectString += Mid(Ability_Affect2Modifier.Text, 1, 2) + ","
            If Ability_Affect2Cure.Enabled = True Then AffectString += Mid(Ability_Affect2Cure.Text, 1, 1) + ","
            If Ability_Affect2Timed.Enabled = True Then AffectString += Mid(Ability_Affect2Timed.Text, 1, 1) + ","
            If Ability_Affect2TimeAmount.Enabled = True Then AffectString += LTrim(Ability_Affect2TimeAmount.Text) + ","
            If GB4.Enabled = True Then AffectString += LTrim(Ability_Affect2SummonHP.Text) + "." + LTrim(Ability_Affect2SummonWP.Text) + "." + LTrim(Ability_Affect2SummonSP.Text) + ","
            AffectString = Mid(AffectString, 1, Len(AffectString) - 1)
            SND("/wAFFE2/z#" + astr + "/W(/c" + AffectString + "/W)")
            AbilityData += Chr(13) + "AFFE2#" + astr + "(" + AffectString + ")"
            AffectString = Mid(Ability_Affect3Type.Text, 1, 2) + ","
            If Ability_Affect3Damage.Enabled = True Then AffectString += Mid(Ability_Affect3Damage.Text, 1, 2) + ","
            If GB5.Enabled = True Then
                If A3RB1.Checked = True Then
                    AffectString += A3DB1.Text + "HP,"
                ElseIf A3RB2.Checked = True Then
                    AffectString += A3DB2.Text + "WP,"
                ElseIf A3RB3.Checked = True Then
                    AffectString += A3DB3.Text + "SP,"
                ElseIf A3RB4.Checked = True Then
                    AffectString += A3DB4a.Text + A3DB4b.Text + "+" + A3DB4d.Text + "." + Mid(A3DB4c.Text, 1, 1) + Mid(A3DB4e.Text, 1, 2) + ","
                ElseIf A3RB5.Checked = True Then
                    AffectString += A3DB5.Text + "HP,"
                ElseIf A3RB6.Checked = True Then
                    AffectString += A3DB6.Text + "WP,"
                ElseIf A3RB7.Checked = True Then
                    AffectString += A3DB7.Text + "SP,"
                End If
            End If
            If Ability_Affect3Healing.Enabled = True Then AffectString += Mid(Ability_Affect3Healing.Text, 1, 1) + ","
            If Ability_Affect3Target.Enabled = True Then AffectString += Mid(Ability_Affect3Target.Text, 1, 1) + ","
            If Ability_Affect3Modifier.Enabled = True Then AffectString += Mid(Ability_Affect3Modifier.Text, 1, 2) + ","
            If Ability_Affect3Cure.Enabled = True Then AffectString += Mid(Ability_Affect3Cure.Text, 1, 1) + ","
            If Ability_Affect3Timed.Enabled = True Then AffectString += Mid(Ability_Affect3Timed.Text, 1, 1) + ","
            If Ability_Affect3TimeAmount.Enabled = True Then AffectString += LTrim(Ability_Affect3TimeAmount.Text) + ","
            If GB6.Enabled = True Then AffectString += LTrim(Ability_Affect3SummonHP.Text) + "." + LTrim(Ability_Affect3SummonWP.Text) + "." + LTrim(Ability_Affect3SummonSP.Text) + ","
            AffectString = Mid(AffectString, 1, Len(AffectString) - 1)
            SND("/wAFFE3/z#" + astr + "/W(/c" + AffectString + "/W)")
            AbilityData += Chr(13) + "AFFE3#" + astr + "(" + AffectString + ")"
        ElseIf Ability_Affect4.Checked = True Then
            SND("/wAFNUM/z#" + astr + "/W(/c4/W)")
            AbilityData += Chr(13) + "AFNUM#" + astr + "(4)"
            AffectString = Mid(Ability_Affect1Type.Text, 1, 2) + ","
            If Ability_Affect1Damage.Enabled = True Then AffectString += Mid(Ability_Affect1Damage.Text, 1, 2) + ","
            If GB1.Enabled = True Then
                If A1RB1.Checked = True Then
                    AffectString += A1DB1.Text + "HP,"
                ElseIf A1RB2.Checked = True Then
                    AffectString += A1DB2.Text + "WP,"
                ElseIf A1RB3.Checked = True Then
                    AffectString += A1DB3.Text + "SP,"
                ElseIf A1RB4.Checked = True Then
                    AffectString += A1DB4a.Text + A1DB4b.Text + "+" + A1DB4d.Text + "." + Mid(A1DB4c.Text, 1, 1) + Mid(A1DB4e.Text, 1, 2) + ","
                ElseIf A1RB5.Checked = True Then
                    AffectString += A1DB5.Text + "HP,"
                ElseIf A1RB6.Checked = True Then
                    AffectString += A1DB6.Text + "WP,"
                ElseIf A1RB7.Checked = True Then
                    AffectString += A1DB7.Text + "SP,"
                End If
            End If
            If Ability_Affect1Healing.Enabled = True Then AffectString += Mid(Ability_Affect1Healing.Text, 1, 1) + ","
            If Ability_Affect1Target.Enabled = True Then AffectString += Mid(Ability_Affect1Target.Text, 1, 1) + ","
            If Ability_Affect1Modifier.Enabled = True Then AffectString += Mid(Ability_Affect1Modifier.Text, 1, 2) + ","
            If Ability_Affect1Cure.Enabled = True Then AffectString += Mid(Ability_Affect1Cure.Text, 1, 1) + ","
            If Ability_Affect1Timed.Enabled = True Then AffectString += Mid(Ability_Affect1Timed.Text, 1, 1) + ","
            If Ability_Affect1TimeAmount.Enabled = True Then AffectString += LTrim(Ability_Affect1TimeAmount.Text) + ","
            If GB2.Enabled = True Then AffectString += LTrim(Ability_Affect1SummonHP.Text) + "." + LTrim(Ability_Affect1SummonWP.Text) + "." + LTrim(Ability_Affect1SummonSP.Text) + ","
            AffectString = Mid(AffectString, 1, Len(AffectString) - 1)
            SND("/wAFFE1/z#" + astr + "/W(/c" + AffectString + "/W)")
            AbilityData += Chr(13) + "AFFE1#" + astr + "(" + AffectString + ")"
            AffectString = Mid(Ability_Affect2Type.Text, 1, 2) + ","
            If Ability_Affect2Damage.Enabled = True Then AffectString += Mid(Ability_Affect2Damage.Text, 1, 2) + ","
            If GB3.Enabled = True Then
                If A2RB1.Checked = True Then
                    AffectString += A2DB1.Text + "HP,"
                ElseIf A2RB2.Checked = True Then
                    AffectString += A2DB2.Text + "WP,"
                ElseIf A2RB3.Checked = True Then
                    AffectString += A2DB3.Text + "SP,"
                ElseIf A2RB4.Checked = True Then
                    AffectString += A2DB4a.Text + A2DB4b.Text + "+" + A2DB4d.Text + "." + Mid(A2DB4c.Text, 1, 1) + Mid(A2DB4e.Text, 1, 2) + ","
                ElseIf A2RB5.Checked = True Then
                    AffectString += A2DB5.Text + "HP,"
                ElseIf A2RB6.Checked = True Then
                    AffectString += A2DB6.Text + "WP,"
                ElseIf A2RB7.Checked = True Then
                    AffectString += A2DB7.Text + "SP,"
                End If
            End If
            If Ability_Affect2Healing.Enabled = True Then AffectString += Mid(Ability_Affect2Healing.Text, 1, 1) + ","
            If Ability_Affect2Target.Enabled = True Then AffectString += Mid(Ability_Affect2Target.Text, 1, 1) + ","
            If Ability_Affect2Modifier.Enabled = True Then AffectString += Mid(Ability_Affect2Modifier.Text, 1, 2) + ","
            If Ability_Affect2Cure.Enabled = True Then AffectString += Mid(Ability_Affect2Cure.Text, 1, 1) + ","
            If Ability_Affect2Timed.Enabled = True Then AffectString += Mid(Ability_Affect2Timed.Text, 1, 1) + ","
            If Ability_Affect2TimeAmount.Enabled = True Then AffectString += LTrim(Ability_Affect2TimeAmount.Text) + ","
            If GB4.Enabled = True Then AffectString += LTrim(Ability_Affect2SummonHP.Text) + "." + LTrim(Ability_Affect2SummonWP.Text) + "." + LTrim(Ability_Affect2SummonSP.Text) + ","
            AffectString = Mid(AffectString, 1, Len(AffectString) - 1)
            SND("/wAFFE2/z#" + astr + "/W(/c" + AffectString + "/W)")
            AbilityData += Chr(13) + "AFFE2#" + astr + "(" + AffectString + ")"
            AffectString = Mid(Ability_Affect3Type.Text, 1, 2) + ","
            If Ability_Affect3Damage.Enabled = True Then AffectString += Mid(Ability_Affect3Damage.Text, 1, 2) + ","
            If GB5.Enabled = True Then
                If A3RB1.Checked = True Then
                    AffectString += A3DB1.Text + "HP,"
                ElseIf A3RB2.Checked = True Then
                    AffectString += A3DB2.Text + "WP,"
                ElseIf A3RB3.Checked = True Then
                    AffectString += A3DB3.Text + "SP,"
                ElseIf A3RB4.Checked = True Then
                    AffectString += A3DB4a.Text + A3DB4b.Text + "+" + A3DB4d.Text + "." + Mid(A3DB4c.Text, 1, 1) + Mid(A3DB4e.Text, 1, 2) + ","
                ElseIf A3RB5.Checked = True Then
                    AffectString += A3DB5.Text + "HP,"
                ElseIf A3RB6.Checked = True Then
                    AffectString += A3DB6.Text + "WP,"
                ElseIf A3RB7.Checked = True Then
                    AffectString += A3DB7.Text + "SP,"
                End If
            End If
            If Ability_Affect3Healing.Enabled = True Then AffectString += Mid(Ability_Affect3Healing.Text, 1, 1) + ","
            If Ability_Affect3Target.Enabled = True Then AffectString += Mid(Ability_Affect3Target.Text, 1, 1) + ","
            If Ability_Affect3Modifier.Enabled = True Then AffectString += Mid(Ability_Affect3Modifier.Text, 1, 2) + ","
            If Ability_Affect3Cure.Enabled = True Then AffectString += Mid(Ability_Affect3Cure.Text, 1, 1) + ","
            If Ability_Affect3Timed.Enabled = True Then AffectString += Mid(Ability_Affect3Timed.Text, 1, 1) + ","
            If Ability_Affect3TimeAmount.Enabled = True Then AffectString += LTrim(Ability_Affect3TimeAmount.Text) + ","
            If GB6.Enabled = True Then AffectString += LTrim(Ability_Affect3SummonHP.Text) + "." + LTrim(Ability_Affect3SummonWP.Text) + "." + LTrim(Ability_Affect3SummonSP.Text) + ","
            AffectString = Mid(AffectString, 1, Len(AffectString) - 1)
            SND("/wAFFE3/z#" + astr + "/W(/c" + AffectString + "/W)")
            AbilityData += Chr(13) + "AFFE3#" + astr + "(" + AffectString + ")"
            AffectString = Mid(Ability_Affect4Type.Text, 1, 2) + ","
            If Ability_Affect4Damage.Enabled = True Then AffectString += Mid(Ability_Affect4Damage.Text, 1, 2) + ","
            If GB7.Enabled = True Then
                If A4RB1.Checked = True Then
                    AffectString += A4DB1.Text + "HP,"
                ElseIf A4RB2.Checked = True Then
                    AffectString += A4DB2.Text + "WP,"
                ElseIf A4RB3.Checked = True Then
                    AffectString += A4DB3.Text + "SP,"
                ElseIf A4RB4.Checked = True Then
                    AffectString += A4DB4a.Text + A4DB4b.Text + "+" + A4DB4d.Text + "." + Mid(A4DB4c.Text, 1, 1) + Mid(A4DB4e.Text, 1, 2) + ","
                ElseIf A4RB5.Checked = True Then
                    AffectString += A4DB5.Text + "HP,"
                ElseIf A4RB6.Checked = True Then
                    AffectString += A4DB6.Text + "WP,"
                ElseIf A4RB7.Checked = True Then
                    AffectString += A4DB7.Text + "SP,"
                End If
            End If
            If Ability_Affect4Healing.Enabled = True Then AffectString += Mid(Ability_Affect4Healing.Text, 1, 1) + ","
            If Ability_Affect4Target.Enabled = True Then AffectString += Mid(Ability_Affect4Target.Text, 1, 1) + ","
            If Ability_Affect4Modifier.Enabled = True Then AffectString += Mid(Ability_Affect4Modifier.Text, 1, 2) + ","
            If Ability_Affect4Cure.Enabled = True Then AffectString += Mid(Ability_Affect4Cure.Text, 1, 1) + ","
            If Ability_Affect4Timed.Enabled = True Then AffectString += Mid(Ability_Affect4Timed.Text, 1, 1) + ","
            If Ability_Affect4TimeAmount.Enabled = True Then AffectString += LTrim(Ability_Affect4TimeAmount.Text) + ","
            If GB8.Enabled = True Then AffectString += LTrim(Ability_Affect4SummonHP.Text) + "." + LTrim(Ability_Affect4SummonWP.Text) + "." + LTrim(Ability_Affect4SummonSP.Text) + ","
            AffectString = Mid(AffectString, 1, Len(AffectString) - 1)
            SND("/wAFFE4/z#" + astr + "/W(/c" + AffectString + "/W)")
            AbilityData += Chr(13) + "AFFE4#" + astr + "(" + AffectString + ")"
        End If
        SND("/wENDAB/z#" + astr + "/W(/c" + comments.Text + "/W)")
        AbilityData += Chr(13) + "ENDAB#" + astr + "(" + comments.Text + "%p45)"
        If errornum = 0 Then
            If overwrite = True Then
                Dim tmp1 As Integer
                Dim tmp2 As Integer
                Dim tmp3 As Integer
                For tmp1 = 1 To Len(tAbilityData) Step 1
                    If Mid(tAbilityData, tmp1, 6 + Len(VIRID.Text)) = "VIRID#" + VIRID.Text Then
                        tmp2 = tmp1
                    End If
                    If Mid(tAbilityData, tmp1, 6 + Len(VIRID.Text)) = "ENDAB#" + VIRID.Text Then
                        For tmp3 = tmp2 To Len(tAbilityData) Step 1
                            If Mid(tAbilityData, tmp3, 5) = "%p45)" Then
                                tmp3 += 5
                                Exit For
                            End If
                        Next
                        Exit For
                    End If
                Next
                SND("/GAbility successfully overwritten.")
                AbilityData = Replace(tAbilityData, Mid(tAbilityData, tmp2 - 2, tmp3 - tmp2 + 2), LTrim(AbilityData))
            End If
            SaveTextToFile(AbilityData, Debugger.DirAbilities)
            LoadAbility.Text = astr + ". " + Ability_Name.Text
            If overwrite = False Then SND("/GAbility has been added to database successfully.")
        Else
            SND("/R" + LTrim(Str(errornum)) + " Errors were found.")
            SND("/RAbility was not compiled or saved.")
        End If
    End Sub

    Private Sub RBCostCheckChange(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RB1.CheckedChanged, RB5.CheckedChanged, RB3.CheckedChanged, RB2.CheckedChanged
        If RB1.Checked = True Then
            AC1.Enabled = True
            AC2.Enabled = False
            AC3.Enabled = False
            AC5a.Enabled = False
            AC5b.Enabled = False
        ElseIf RB2.Checked = True Then
            AC1.Enabled = False
            AC2.Enabled = True
            AC3.Enabled = False
            AC5a.Enabled = False
            AC5b.Enabled = False
        ElseIf RB3.Checked = True Then
            AC1.Enabled = False
            AC2.Enabled = False
            AC3.Enabled = True
            AC5a.Enabled = False
            AC5b.Enabled = False
        ElseIf RB5.Checked = True Then
            AC1.Enabled = False
            AC2.Enabled = False
            AC3.Enabled = False
            AC5a.Enabled = True
            AC5b.Enabled = True
        End If
    End Sub

    Private Sub Ability_Affect2Define(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Ability_Affect2Type.SelectedIndexChanged
        If Ability_Affect2Type.SelectedIndex = 0 Then 'Damaging Type
            Ability_Affect2Damage.Enabled = True
            GB3.Enabled = True
            GB4.Enabled = False
            Ability_Affect2Healing.Enabled = False
            Ability_Affect2Modifier.Enabled = False
            Ability_Affect2Target.Enabled = True
            Ability_Affect2Timed.Enabled = True
            Ability_Affect2TimeAmount.Enabled = True
            Ability_Affect2Cure.Enabled = False
        ElseIf Ability_Affect2Type.SelectedIndex = 1 Then 'Healing Type
            Ability_Affect2Damage.Enabled = False
            GB3.Enabled = True
            GB4.Enabled = False
            Ability_Affect2Healing.Enabled = True
            Ability_Affect2Modifier.Enabled = False
            Ability_Affect2Target.Enabled = True
            Ability_Affect2Timed.Enabled = True
            Ability_Affect2TimeAmount.Enabled = True
            Ability_Affect2Cure.Enabled = False
        ElseIf Ability_Affect2Type.SelectedIndex = 2 Then 'Blind Type
            Ability_Affect2Damage.Enabled = False
            GB3.Enabled = False
            GB4.Enabled = False
            Ability_Affect2Healing.Enabled = False
            Ability_Affect2Modifier.Enabled = False
            Ability_Affect2Target.Enabled = True
            Ability_Affect2Timed.Enabled = True
            Ability_Affect2TimeAmount.Enabled = True
            Ability_Affect2Cure.Enabled = False
        ElseIf Ability_Affect2Type.SelectedIndex = 3 Then 'Silence Type
            Ability_Affect2Damage.Enabled = False
            GB3.Enabled = False
            GB4.Enabled = False
            Ability_Affect2Healing.Enabled = False
            Ability_Affect2Modifier.Enabled = False
            Ability_Affect2Target.Enabled = True
            Ability_Affect2Timed.Enabled = True
            Ability_Affect2TimeAmount.Enabled = True
            Ability_Affect2Cure.Enabled = False
        ElseIf Ability_Affect2Type.SelectedIndex = 4 Then 'Poison Type
            Ability_Affect2Damage.Enabled = True
            GB3.Enabled = True
            GB4.Enabled = False
            Ability_Affect2Healing.Enabled = False
            Ability_Affect2Modifier.Enabled = False
            Ability_Affect2Target.Enabled = True
            Ability_Affect2Timed.Enabled = True
            Ability_Affect2TimeAmount.Enabled = True
            Ability_Affect2Cure.Enabled = False
        ElseIf Ability_Affect2Type.SelectedIndex = 5 Then 'Disease Type
            Ability_Affect2Damage.Enabled = True
            GB3.Enabled = True
            GB4.Enabled = False
            Ability_Affect2Healing.Enabled = False
            Ability_Affect2Modifier.Enabled = False
            Ability_Affect2Target.Enabled = True
            Ability_Affect2Timed.Enabled = True
            Ability_Affect2TimeAmount.Enabled = True
            Ability_Affect2Cure.Enabled = False
        ElseIf Ability_Affect2Type.SelectedIndex = 6 Then 'Speed Type
            Ability_Affect2Damage.Enabled = False
            GB3.Enabled = False
            GB4.Enabled = False
            Ability_Affect2Healing.Enabled = False
            Ability_Affect2Modifier.Enabled = False
            Ability_Affect2Target.Enabled = True
            Ability_Affect2Timed.Enabled = True
            Ability_Affect2TimeAmount.Enabled = True
            Ability_Affect2Cure.Enabled = False
        ElseIf Ability_Affect2Type.SelectedIndex = 7 Then 'Summon Type
            Ability_Affect2Damage.Enabled = True
            GB3.Enabled = True
            GB4.Enabled = True
            Ability_Affect2Healing.Enabled = False
            Ability_Affect2Modifier.Enabled = False
            Ability_Affect2Target.Enabled = False
            Ability_Affect2Timed.Enabled = True
            Ability_Affect2TimeAmount.Enabled = True
            Ability_Affect2Cure.Enabled = False
        ElseIf Ability_Affect2Type.SelectedIndex = 8 Then 'Stats Modifier Type
            Ability_Affect2Damage.Enabled = False
            GB3.Enabled = False
            GB4.Enabled = False
            Ability_Affect2Healing.Enabled = False
            Ability_Affect2Modifier.Enabled = True
            Ability_Affect2Target.Enabled = True
            Ability_Affect2Timed.Enabled = True
            Ability_Affect2TimeAmount.Enabled = True
            Ability_Affect2Cure.Enabled = False
        ElseIf Ability_Affect2Type.SelectedIndex = 9 Then 'Aura Type
            Ability_Affect2Damage.Enabled = False
            GB3.Enabled = False
            GB4.Enabled = False
            Ability_Affect2Healing.Enabled = False
            Ability_Affect2Modifier.Enabled = False
            Ability_Affect2Target.Enabled = True
            Ability_Affect2Timed.Enabled = True
            Ability_Affect2TimeAmount.Enabled = True
            Ability_Affect2Cure.Enabled = False
        ElseIf Ability_Affect2Type.SelectedIndex = 10 Then 'Fear Type
            Ability_Affect2Damage.Enabled = False
            GB3.Enabled = False
            GB4.Enabled = False
            Ability_Affect2Healing.Enabled = False
            Ability_Affect2Modifier.Enabled = False
            Ability_Affect2Target.Enabled = True
            Ability_Affect2Timed.Enabled = True
            Ability_Affect2TimeAmount.Enabled = True
            Ability_Affect2Cure.Enabled = False
        ElseIf Ability_Affect2Type.SelectedIndex = 11 Then 'Cripple Type
            Ability_Affect2Damage.Enabled = False
            GB3.Enabled = False
            GB4.Enabled = False
            Ability_Affect2Healing.Enabled = False
            Ability_Affect2Modifier.Enabled = False
            Ability_Affect2Target.Enabled = True
            Ability_Affect2Timed.Enabled = True
            Ability_Affect2TimeAmount.Enabled = True
            Ability_Affect2Cure.Enabled = False
        ElseIf Ability_Affect2Type.SelectedIndex = 12 Then 'Stun
            Ability_Affect2Damage.Enabled = False
            GB3.Enabled = False
            GB4.Enabled = False
            Ability_Affect2Healing.Enabled = False
            Ability_Affect2Modifier.Enabled = False
            Ability_Affect2Target.Enabled = True
            Ability_Affect2Timed.Enabled = True
            Ability_Affect2TimeAmount.Enabled = True
            Ability_Affect2Cure.Enabled = False
        ElseIf Ability_Affect2Type.SelectedIndex = 13 Then 'Cure
            Ability_Affect2Damage.Enabled = False
            GB3.Enabled = False
            GB4.Enabled = False
            Ability_Affect2Healing.Enabled = False
            Ability_Affect2Modifier.Enabled = False
            Ability_Affect2Target.Enabled = True
            Ability_Affect2Timed.Enabled = False
            Ability_Affect2TimeAmount.Enabled = False
            Ability_Affect2Cure.Enabled = True
        End If
    End Sub

    Private Sub Ability_Affect3Define(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Ability_Affect3Type.SelectedIndexChanged
        If Ability_Affect3Type.SelectedIndex = 0 Then 'Damaging Type
            Ability_Affect3Damage.Enabled = True
            GB5.Enabled = True
            GB6.Enabled = False
            Ability_Affect3Healing.Enabled = False
            Ability_Affect3Modifier.Enabled = False
            Ability_Affect3Target.Enabled = True
            Ability_Affect3Timed.Enabled = True
            Ability_Affect3TimeAmount.Enabled = True
            Ability_Affect3Cure.Enabled = False
        ElseIf Ability_Affect3Type.SelectedIndex = 1 Then 'Healing Type
            Ability_Affect3Damage.Enabled = False
            GB5.Enabled = True
            GB6.Enabled = False
            Ability_Affect3Healing.Enabled = True
            Ability_Affect3Modifier.Enabled = False
            Ability_Affect3Target.Enabled = True
            Ability_Affect3Timed.Enabled = True
            Ability_Affect3TimeAmount.Enabled = True
            Ability_Affect3Cure.Enabled = False
        ElseIf Ability_Affect3Type.SelectedIndex = 2 Then 'Blind Type
            Ability_Affect3Damage.Enabled = False
            GB5.Enabled = False
            GB6.Enabled = False
            Ability_Affect3Healing.Enabled = False
            Ability_Affect3Modifier.Enabled = False
            Ability_Affect3Target.Enabled = True
            Ability_Affect3Timed.Enabled = True
            Ability_Affect3TimeAmount.Enabled = True
            Ability_Affect3Cure.Enabled = False
        ElseIf Ability_Affect3Type.SelectedIndex = 3 Then 'Silence Type
            Ability_Affect3Damage.Enabled = False
            GB5.Enabled = False
            GB6.Enabled = False
            Ability_Affect3Healing.Enabled = False
            Ability_Affect3Modifier.Enabled = False
            Ability_Affect3Target.Enabled = True
            Ability_Affect3Timed.Enabled = True
            Ability_Affect3TimeAmount.Enabled = True
            Ability_Affect3Cure.Enabled = False
        ElseIf Ability_Affect3Type.SelectedIndex = 4 Then 'Poison Type
            Ability_Affect3Damage.Enabled = True
            GB5.Enabled = True
            GB6.Enabled = False
            Ability_Affect3Healing.Enabled = False
            Ability_Affect3Modifier.Enabled = False
            Ability_Affect3Target.Enabled = True
            Ability_Affect3Timed.Enabled = True
            Ability_Affect3TimeAmount.Enabled = True
            Ability_Affect3Cure.Enabled = False
        ElseIf Ability_Affect3Type.SelectedIndex = 5 Then 'Disease Type
            Ability_Affect3Damage.Enabled = True
            GB5.Enabled = True
            GB6.Enabled = False
            Ability_Affect3Healing.Enabled = False
            Ability_Affect3Modifier.Enabled = False
            Ability_Affect3Target.Enabled = True
            Ability_Affect3Timed.Enabled = True
            Ability_Affect3TimeAmount.Enabled = True
            Ability_Affect3Cure.Enabled = False
        ElseIf Ability_Affect3Type.SelectedIndex = 6 Then 'Speed Type
            Ability_Affect3Damage.Enabled = False
            GB5.Enabled = False
            GB6.Enabled = False
            Ability_Affect3Healing.Enabled = False
            Ability_Affect3Modifier.Enabled = False
            Ability_Affect3Target.Enabled = True
            Ability_Affect3Timed.Enabled = True
            Ability_Affect3TimeAmount.Enabled = True
            Ability_Affect3Cure.Enabled = False
        ElseIf Ability_Affect3Type.SelectedIndex = 7 Then 'Summon Type
            Ability_Affect3Damage.Enabled = True
            GB5.Enabled = True
            GB6.Enabled = True
            Ability_Affect3Healing.Enabled = False
            Ability_Affect3Modifier.Enabled = False
            Ability_Affect3Target.Enabled = False
            Ability_Affect3Timed.Enabled = True
            Ability_Affect3TimeAmount.Enabled = True
            Ability_Affect3Cure.Enabled = False
        ElseIf Ability_Affect3Type.SelectedIndex = 8 Then 'Stats Modifier Type
            Ability_Affect3Damage.Enabled = False
            GB5.Enabled = False
            GB6.Enabled = False
            Ability_Affect3Healing.Enabled = False
            Ability_Affect3Modifier.Enabled = True
            Ability_Affect3Target.Enabled = True
            Ability_Affect3Timed.Enabled = True
            Ability_Affect3TimeAmount.Enabled = True
            Ability_Affect3Cure.Enabled = False
        ElseIf Ability_Affect3Type.SelectedIndex = 9 Then 'Aura Type
            Ability_Affect3Damage.Enabled = False
            GB5.Enabled = False
            GB6.Enabled = False
            Ability_Affect3Healing.Enabled = False
            Ability_Affect3Modifier.Enabled = False
            Ability_Affect3Target.Enabled = True
            Ability_Affect3Timed.Enabled = True
            Ability_Affect3TimeAmount.Enabled = True
            Ability_Affect3Cure.Enabled = False
        ElseIf Ability_Affect3Type.SelectedIndex = 10 Then 'Fear Type
            Ability_Affect3Damage.Enabled = False
            GB5.Enabled = False
            GB6.Enabled = False
            Ability_Affect3Healing.Enabled = False
            Ability_Affect3Modifier.Enabled = False
            Ability_Affect3Target.Enabled = True
            Ability_Affect3Timed.Enabled = True
            Ability_Affect3TimeAmount.Enabled = True
            Ability_Affect3Cure.Enabled = False
        ElseIf Ability_Affect3Type.SelectedIndex = 11 Then 'Cripple Type
            Ability_Affect3Damage.Enabled = False
            GB5.Enabled = False
            GB6.Enabled = False
            Ability_Affect3Healing.Enabled = False
            Ability_Affect3Modifier.Enabled = False
            Ability_Affect3Target.Enabled = True
            Ability_Affect3Timed.Enabled = True
            Ability_Affect3TimeAmount.Enabled = True
            Ability_Affect3Cure.Enabled = False
        ElseIf Ability_Affect3Type.SelectedIndex = 12 Then 'Stun
            Ability_Affect3Damage.Enabled = False
            GB5.Enabled = False
            GB6.Enabled = False
            Ability_Affect3Healing.Enabled = False
            Ability_Affect3Modifier.Enabled = False
            Ability_Affect3Target.Enabled = True
            Ability_Affect3Timed.Enabled = True
            Ability_Affect3TimeAmount.Enabled = True
            Ability_Affect3Cure.Enabled = False
        ElseIf Ability_Affect3Type.SelectedIndex = 13 Then 'Cure
            Ability_Affect3Damage.Enabled = False
            GB5.Enabled = False
            GB6.Enabled = False
            Ability_Affect3Healing.Enabled = False
            Ability_Affect3Modifier.Enabled = False
            Ability_Affect3Target.Enabled = True
            Ability_Affect3Timed.Enabled = False
            Ability_Affect3TimeAmount.Enabled = False
            Ability_Affect3Cure.Enabled = True
        End If
    End Sub

    Private Sub Ability_Affect4Define(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Ability_Affect4Type.SelectedIndexChanged
        If Ability_Affect4Type.SelectedIndex = 0 Then 'Damaging Type
            Ability_Affect4Damage.Enabled = True
            GB7.Enabled = True
            GB8.Enabled = False
            Ability_Affect4Healing.Enabled = False
            Ability_Affect4Modifier.Enabled = False
            Ability_Affect4Target.Enabled = True
            Ability_Affect4Timed.Enabled = True
            Ability_Affect4TimeAmount.Enabled = True
            Ability_Affect4Cure.Enabled = False
        ElseIf Ability_Affect4Type.SelectedIndex = 1 Then 'Healing Type
            Ability_Affect4Damage.Enabled = False
            GB7.Enabled = True
            GB8.Enabled = False
            Ability_Affect4Healing.Enabled = True
            Ability_Affect4Modifier.Enabled = False
            Ability_Affect4Target.Enabled = True
            Ability_Affect4Timed.Enabled = True
            Ability_Affect4TimeAmount.Enabled = True
            Ability_Affect4Cure.Enabled = False
        ElseIf Ability_Affect4Type.SelectedIndex = 2 Then 'Blind Type
            Ability_Affect4Damage.Enabled = False
            GB7.Enabled = False
            GB8.Enabled = False
            Ability_Affect4Healing.Enabled = False
            Ability_Affect4Modifier.Enabled = False
            Ability_Affect4Target.Enabled = True
            Ability_Affect4Timed.Enabled = True
            Ability_Affect4TimeAmount.Enabled = True
            Ability_Affect4Cure.Enabled = False
        ElseIf Ability_Affect4Type.SelectedIndex = 3 Then 'Silence Type
            Ability_Affect4Damage.Enabled = False
            GB7.Enabled = False
            GB8.Enabled = False
            Ability_Affect4Healing.Enabled = False
            Ability_Affect4Modifier.Enabled = False
            Ability_Affect4Target.Enabled = True
            Ability_Affect4Timed.Enabled = True
            Ability_Affect4TimeAmount.Enabled = True
            Ability_Affect4Cure.Enabled = False
        ElseIf Ability_Affect4Type.SelectedIndex = 4 Then 'Poison Type
            Ability_Affect4Damage.Enabled = True
            GB7.Enabled = True
            GB8.Enabled = False
            Ability_Affect4Healing.Enabled = False
            Ability_Affect4Modifier.Enabled = False
            Ability_Affect4Target.Enabled = True
            Ability_Affect4Timed.Enabled = True
            Ability_Affect4TimeAmount.Enabled = True
            Ability_Affect4Cure.Enabled = False
        ElseIf Ability_Affect4Type.SelectedIndex = 5 Then 'Disease Type
            Ability_Affect4Damage.Enabled = True
            GB7.Enabled = True
            GB8.Enabled = False
            Ability_Affect4Healing.Enabled = False
            Ability_Affect4Modifier.Enabled = False
            Ability_Affect4Target.Enabled = True
            Ability_Affect4Timed.Enabled = True
            Ability_Affect4TimeAmount.Enabled = True
            Ability_Affect4Cure.Enabled = False
        ElseIf Ability_Affect4Type.SelectedIndex = 6 Then 'Speed Type
            Ability_Affect4Damage.Enabled = False
            GB7.Enabled = False
            GB8.Enabled = False
            Ability_Affect4Healing.Enabled = False
            Ability_Affect4Modifier.Enabled = False
            Ability_Affect4Target.Enabled = True
            Ability_Affect4Timed.Enabled = True
            Ability_Affect4TimeAmount.Enabled = True
            Ability_Affect4Cure.Enabled = False
        ElseIf Ability_Affect4Type.SelectedIndex = 7 Then 'Summon Type
            Ability_Affect4Damage.Enabled = True
            GB7.Enabled = True
            GB8.Enabled = True
            Ability_Affect4Healing.Enabled = False
            Ability_Affect4Modifier.Enabled = False
            Ability_Affect4Target.Enabled = False
            Ability_Affect4Timed.Enabled = True
            Ability_Affect4TimeAmount.Enabled = True
            Ability_Affect4Cure.Enabled = False
        ElseIf Ability_Affect4Type.SelectedIndex = 8 Then 'Stats Modifier Type
            Ability_Affect4Damage.Enabled = False
            GB7.Enabled = False
            GB8.Enabled = False
            Ability_Affect4Healing.Enabled = False
            Ability_Affect4Modifier.Enabled = True
            Ability_Affect4Target.Enabled = True
            Ability_Affect4Timed.Enabled = True
            Ability_Affect4TimeAmount.Enabled = True
            Ability_Affect4Cure.Enabled = False
        ElseIf Ability_Affect4Type.SelectedIndex = 9 Then 'Aura Type
            Ability_Affect4Damage.Enabled = False
            GB7.Enabled = False
            GB8.Enabled = False
            Ability_Affect4Healing.Enabled = False
            Ability_Affect4Modifier.Enabled = False
            Ability_Affect4Target.Enabled = True
            Ability_Affect4Timed.Enabled = True
            Ability_Affect4TimeAmount.Enabled = True
            Ability_Affect4Cure.Enabled = False
        ElseIf Ability_Affect4Type.SelectedIndex = 10 Then 'Fear Type
            Ability_Affect4Damage.Enabled = False
            GB7.Enabled = False
            GB8.Enabled = False
            Ability_Affect4Healing.Enabled = False
            Ability_Affect4Modifier.Enabled = False
            Ability_Affect4Target.Enabled = True
            Ability_Affect4Timed.Enabled = True
            Ability_Affect4TimeAmount.Enabled = True
            Ability_Affect4Cure.Enabled = False
        ElseIf Ability_Affect4Type.SelectedIndex = 11 Then 'Cripple Type
            Ability_Affect4Damage.Enabled = False
            GB7.Enabled = False
            GB8.Enabled = False
            Ability_Affect4Healing.Enabled = False
            Ability_Affect4Modifier.Enabled = False
            Ability_Affect4Target.Enabled = True
            Ability_Affect4Timed.Enabled = True
            Ability_Affect4TimeAmount.Enabled = True
            Ability_Affect4Cure.Enabled = False
        ElseIf Ability_Affect4Type.SelectedIndex = 12 Then 'Stun
            Ability_Affect4Damage.Enabled = False
            GB7.Enabled = False
            GB8.Enabled = False
            Ability_Affect4Healing.Enabled = False
            Ability_Affect4Modifier.Enabled = False
            Ability_Affect4Target.Enabled = True
            Ability_Affect4Timed.Enabled = True
            Ability_Affect4TimeAmount.Enabled = True
            Ability_Affect4Cure.Enabled = False
        ElseIf Ability_Affect4Type.SelectedIndex = 13 Then 'Cure
            Ability_Affect4Damage.Enabled = False
            GB7.Enabled = False
            GB8.Enabled = False
            Ability_Affect4Healing.Enabled = False
            Ability_Affect4Modifier.Enabled = False
            Ability_Affect4Target.Enabled = True
            Ability_Affect4Timed.Enabled = False
            Ability_Affect4TimeAmount.Enabled = False
            Ability_Affect4Cure.Enabled = True
        End If
    End Sub

    Private Sub LoadTheAbility(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LoadAbility.SelectedIndexChanged
        Dim npcnum As String = ""
        Dim mscstr As String = ""
        Dim stepnum As Short = 0
        Dim tmp0 As Integer
        Dim tmp1 As Integer
        Dim tmp2 As Integer
        Dim tmp3 As Integer
        For tmp1 = 1 To Len(LoadAbility.Text)
            If Mid(LoadAbility.Text, tmp1, 1) = "." Then
                npcnum = Mid(LoadAbility.Text, 1, tmp1 - 1)
                Exit For
            End If
        Next
        SND("/GLoading mobile number " + npcnum + "...")
        AbilityData = GetFileContents(Debugger.DirAbilities)
        VIRID.Text = npcnum
        VIRID.Enabled = True
        tmp0 = InStr(AbilityData, "SHORT#" + npcnum + "(")
        If tmp0 > 0 Then
            For tmp1 = InStr(AbilityData, "SHORT#" + npcnum + "(") To Len(AbilityData) Step 1
                If Mid(AbilityData, tmp1, 1) = ")" Then
                    Ability_Short.Text = Mid(AbilityData, InStr(AbilityData, "SHORT#" + npcnum + "(") + 7 + Len(npcnum), tmp1 - InStr(AbilityData, "SHORT#" + npcnum + "(") - 7 - Len(npcnum))
                    Exit For
                End If
            Next
        End If
        tmp0 = InStr(AbilityData, "ANAME#" + npcnum + "(")
        If tmp0 > 0 Then
            For tmp1 = InStr(AbilityData, "ANAME#" + npcnum + "(") To Len(AbilityData) Step 1
                If Mid(AbilityData, tmp1, 1) = ")" Then
                    Ability_Name.Text = Mid(AbilityData, InStr(AbilityData, "ANAME#" + npcnum + "(") + 7 + Len(npcnum), tmp1 - InStr(AbilityData, "ANAME#" + npcnum + "(") - 7 - Len(npcnum))
                    Exit For
                End If
            Next
        End If
        tmp0 = InStr(AbilityData, "REQUI#" + npcnum + "(")
        If tmp0 > 0 Then : stepnum = 0
            For tmp1 = InStr(AbilityData, "REQUI#" + npcnum + "(") To Len(AbilityData) Step 1
                If Mid(AbilityData, tmp1, 1) = ")" Then
                    mscstr = Mid(AbilityData, InStr(AbilityData, "REQUI#" + npcnum + "(") + 7 + Len(npcnum), tmp1 - InStr(AbilityData, "REQUI#" + npcnum + "(") - 7 - Len(npcnum))
                    For tmp2 = 1 To Len(mscstr) + 1 Step 1
                        If Mid(mscstr + ",", tmp2, 1) = "," Then
                            If stepnum = 0 Then
                                Ability_ReqClass.SelectedIndex = Val(Mid(mscstr, 1, tmp2 - 1))
                                tmp3 = tmp2 + 1
                                stepnum += 1
                            ElseIf stepnum = 1 Then
                                Ability_ReqLevel.Text = Mid(mscstr, tmp3, tmp2 - tmp3)
                                tmp3 = tmp2 + 1
                                stepnum += 1
                            End If
                        End If
                    Next
                    Exit For
                End If
            Next
        End If
        tmp0 = InStr(AbilityData, "ATIME#" + npcnum + "(")
        If tmp0 > 0 Then
            For tmp1 = InStr(AbilityData, "ATIME#" + npcnum + "(") To Len(AbilityData) Step 1
                If Mid(AbilityData, tmp1, 1) = ")" Then
                    Ability_Time.Text = Mid(AbilityData, InStr(AbilityData, "ATIME#" + npcnum + "(") + 7 + Len(npcnum), tmp1 - InStr(AbilityData, "ATIME#" + npcnum + "(") - 7 - Len(npcnum))
                    Exit For
                End If
            Next
        End If
        tmp0 = InStr(AbilityData, "ACOST#" + npcnum + "(")
        If tmp0 > 0 Then
            For tmp1 = InStr(AbilityData, "ACOST#" + npcnum + "(") To Len(AbilityData) Step 1
                If Mid(AbilityData, tmp1, 1) = ")" Then
                    mscstr = Mid(AbilityData, InStr(AbilityData, "ACOST#" + npcnum + "(") + 7 + Len(npcnum), tmp1 - InStr(AbilityData, "ACOST#" + npcnum + "(") - 7 - Len(npcnum))
                    If InStr(mscstr, "%") Then
                        If InStr(mscstr, "HP") Then
                            RB1.Checked = True
                            AC1.Text = Replace(mscstr, "HP", "")
                        ElseIf InStr(mscstr, "WP") Then
                            RB2.Checked = True
                            AC2.Text = Replace(mscstr, "WP", "")
                        Else
                            RB3.Checked = True
                            AC3.Text = Replace(mscstr, "SP", "")
                        End If
                    Else
                        RB5.Checked = True
                        If InStr(mscstr, "HP") Then
                            AC5a.Text = Replace(mscstr, "HP", "")
                            AC5b.SelectedIndex = 0
                        ElseIf InStr(mscstr, "WP") Then
                            AC5a.Text = Replace(mscstr, "WP", "")
                            AC5b.SelectedIndex = 1
                        Else
                            AC5a.Text = Replace(mscstr, "SP", "")
                            AC5b.SelectedIndex = 2
                        End If
                    End If
                    Exit For
                End If
            Next
        End If
        tmp0 = InStr(AbilityData, "EXHAU#" + npcnum + "(")
        If tmp0 > 0 Then
            For tmp1 = InStr(AbilityData, "EXHAU#" + npcnum + "(") To Len(AbilityData) Step 1
                If Mid(AbilityData, tmp1, 1) = ")" Then
                    mscstr = Mid(AbilityData, InStr(AbilityData, "EXHAU#" + npcnum + "(") + 7 + Len(npcnum), tmp1 - InStr(AbilityData, "EXHAU#" + npcnum + "(") - 7 - Len(npcnum))
                    If mscstr = "1" Then
                        Exhaustion.Checked = True
                    Else
                        Exhaustion.Checked = False
                    End If
                    Exit For
                End If
            Next
        End If
        tmp0 = InStr(AbilityData, "BATOU#" + npcnum + "(")
        If tmp0 > 0 Then
            For tmp1 = InStr(AbilityData, "BATOU#" + npcnum + "(") To Len(AbilityData) Step 1
                If Mid(AbilityData, tmp1, 1) = ")" Then
                    mscstr = Mid(AbilityData, InStr(AbilityData, "BATOU#" + npcnum + "(") + 7 + Len(npcnum), tmp1 - InStr(AbilityData, "BATOU#" + npcnum + "(") - 7 - Len(npcnum))
                    If mscstr = "1" Then
                        OBattle.Checked = True
                    Else
                        OBattle.Checked = False
                    End If
                    Exit For
                End If
            Next
        End If
        tmp0 = InStr(AbilityData, "BATIN#" + npcnum + "(")
        If tmp0 > 0 Then
            For tmp1 = InStr(AbilityData, "BATIN#" + npcnum + "(") To Len(AbilityData) Step 1
                If Mid(AbilityData, tmp1, 1) = ")" Then
                    mscstr = Mid(AbilityData, InStr(AbilityData, "BATIN#" + npcnum + "(") + 7 + Len(npcnum), tmp1 - InStr(AbilityData, "BATIN#" + npcnum + "(") - 7 - Len(npcnum))
                    If mscstr = "1" Then
                        IBattle.Checked = True
                    Else
                        IBattle.Checked = False
                    End If
                    Exit For
                End If
            Next
        End If
        tmp0 = InStr(AbilityData, "AFNUM#" + npcnum + "(")
        If tmp0 > 0 Then
            For tmp1 = InStr(AbilityData, "AFNUM#" + npcnum + "(") To Len(AbilityData) Step 1
                If Mid(AbilityData, tmp1, 1) = ")" Then
                    mscstr = Mid(AbilityData, InStr(AbilityData, "AFNUM#" + npcnum + "(") + 7 + Len(npcnum), tmp1 - InStr(AbilityData, "AFNUM#" + npcnum + "(") - 7 - Len(npcnum))
                    If mscstr = 1 Then
                        Ability_Affect1.Checked = True
                    ElseIf mscstr = 2 Then
                        Ability_Affect2.Checked = True
                    ElseIf mscstr = 3 Then
                        Ability_Affect3.Checked = True
                    Else
                        Ability_Affect4.Checked = True
                    End If
                    Exit For
                End If
            Next
        End If
        tmp0 = InStr(AbilityData, "AFFE1#" + npcnum + "(")
        If tmp0 > 0 Then
            For tmp1 = InStr(AbilityData, "AFFE1#" + npcnum + "(") To Len(AbilityData) Step 1
                If Mid(AbilityData, tmp1, 1) = ")" Then
                    mscstr = Mid(AbilityData, InStr(AbilityData, "AFFE1#" + npcnum + "(") + 7 + Len(npcnum), tmp1 - InStr(AbilityData, "AFFE1#" + npcnum + "(") - 7 - Len(npcnum))
                    Dim AbilityType As String = ""
                    stepnum = 0
                    For tmp2 = 1 To Len(mscstr) + 1 Step 1
                        If Mid(mscstr + ",", tmp2, 1) = "," Then
                            If stepnum = 0 Then
                                If Mid(mscstr, 1, tmp2 - 1) = "00" Then
                                    AbilityType = "Damaging"
                                    Ability_Affect1Type.SelectedIndex = 0
                                ElseIf Mid(mscstr, 1, tmp2 - 1) = "01" Then
                                    AbilityType = "Healing"
                                    Ability_Affect1Type.SelectedIndex = 1
                                ElseIf Mid(mscstr, 1, tmp2 - 1) = "02" Then
                                    AbilityType = "Blind"
                                    Ability_Affect1Type.SelectedIndex = 2
                                ElseIf Mid(mscstr, 1, tmp2 - 1) = "03" Then
                                    AbilityType = "Silence"
                                    Ability_Affect1Type.SelectedIndex = 3
                                ElseIf Mid(mscstr, 1, tmp2 - 1) = "04" Then
                                    AbilityType = "Poison"
                                    Ability_Affect1Type.SelectedIndex = 4
                                ElseIf Mid(mscstr, 1, tmp2 - 1) = "05" Then
                                    AbilityType = "Disease"
                                    Ability_Affect1Type.SelectedIndex = 5
                                ElseIf Mid(mscstr, 1, tmp2 - 1) = "06" Then
                                    AbilityType = "Speed"
                                    Ability_Affect1Type.SelectedIndex = 6
                                ElseIf Mid(mscstr, 1, tmp2 - 1) = "07" Then
                                    AbilityType = "Summon"
                                    Ability_Affect1Type.SelectedIndex = 7
                                ElseIf Mid(mscstr, 1, tmp2 - 1) = "08" Then
                                    AbilityType = "Stats Modifier"
                                    Ability_Affect1Type.SelectedIndex = 8
                                ElseIf Mid(mscstr, 1, tmp2 - 1) = "09" Then
                                    AbilityType = "Aura"
                                    Ability_Affect1Type.SelectedIndex = 9
                                ElseIf Mid(mscstr, 1, tmp2 - 1) = "10" Then
                                    AbilityType = "Fear"
                                    Ability_Affect1Type.SelectedIndex = 10
                                ElseIf Mid(mscstr, 1, tmp2 - 1) = "11" Then
                                    AbilityType = "Cripple"
                                    Ability_Affect1Type.SelectedIndex = 11
                                ElseIf Mid(mscstr, 1, tmp2 - 1) = "12" Then
                                    AbilityType = "Stun"
                                    Ability_Affect1Type.SelectedIndex = 12
                                ElseIf Mid(mscstr, 1, tmp2 - 1) = "13" Then
                                    AbilityType = "Cure"
                                    Ability_Affect1Type.SelectedIndex = 13
                                End If
                                tmp3 = tmp2 + 1
                                stepnum += 1
                            ElseIf stepnum = 1 Then
                                If AbilityType = "Damaging" Then
                                    Ability_Affect1Damage.SelectedIndex = Val(Mid(mscstr, tmp3, tmp2 - tmp3))
                                ElseIf AbilityType = "Healing" Then
                                    If InStr(Mid(mscstr, tmp3, tmp2 - tmp3), "%") Then
                                        If InStr(Mid(mscstr, tmp3, tmp2 - tmp3), "HP") Then
                                            A1RB1.Checked = True
                                            A1DB1.Text = Replace(Mid(mscstr, tmp3, tmp2 - tmp3), "HP", "")
                                        ElseIf InStr(Mid(mscstr, tmp3, tmp2 - tmp3), "WP") Then
                                            A1RB2.Checked = True
                                            A1DB2.Text = Replace(Mid(mscstr, tmp3, tmp2 - tmp3), "WP", "")
                                        Else
                                            A1RB3.Checked = True
                                            A1DB3.Text = Replace(Mid(mscstr, tmp3, tmp2 - tmp3), "SP", "")
                                        End If
                                    ElseIf InStr(Mid(mscstr, tmp3, tmp2 - tmp3), "+") Then
                                        A1RB4.Checked = True
                                        Dim tmp4 As Integer, tmpa As String = Mid(mscstr, tmp3, tmp2 - tmp3), tmpstep As Integer = 0, tmp5 As Integer
                                        For tmp4 = 1 To Len(tmpa) Step 1
                                            If Mid(tmpa, tmp4, 1) = "d" Then
                                                A1DB4a.Text = Mid(tmpa, 1, tmp4 - 1)
                                                tmpstep += 1
                                                tmp5 = tmp4 + 1
                                            ElseIf Mid(tmpa, tmp4, 1) = "+" Then
                                                A1DB4b.Text = Mid(tmpa, tmp5 - 1, tmp4 - tmp5 + 1)
                                                tmpstep += 1
                                                tmp5 = tmp4 + 1
                                            ElseIf Mid(tmpa, tmp4, 1) = "." Then
                                                A1DB4d.Text = Mid(tmpa, tmp5, tmp4 - tmp5)
                                                tmpstep += 1
                                                tmp5 = tmp4 + 1
                                            ElseIf Mid(tmpa, tmp4, 2) = "HP" Then
                                                A1DB4c.SelectedIndex = Val(Mid(tmpa, tmp5, tmp4 - tmp5))
                                                A1DB4e.SelectedIndex = 0
                                                Exit For
                                            ElseIf Mid(tmpa, tmp4, 2) = "WP" Then
                                                A1DB4c.SelectedIndex = Val(Mid(tmpa, tmp5, tmp4 - tmp5))
                                                A1DB4e.SelectedIndex = 1
                                                Exit For
                                            ElseIf Mid(tmpa, tmp4, 2) = "SP" Then
                                                A1DB4c.SelectedIndex = Val(Mid(tmpa, tmp5, tmp4 - tmp5))
                                                A1DB4e.SelectedIndex = 2
                                                Exit For
                                            End If
                                        Next
                                    Else
                                        If InStr(Mid(mscstr, tmp3, tmp2 - tmp3), "HP") Then
                                            A1RB5.Checked = True
                                            A1DB5.Text = Replace(Mid(mscstr, tmp3, tmp2 - tmp3), "HP", "")
                                        ElseIf InStr(Mid(mscstr, tmp3, tmp2 - tmp3), "WP") Then
                                            A1RB6.Checked = True
                                            A1DB6.Text = Replace(Mid(mscstr, tmp3, tmp2 - tmp3), "WP", "")
                                        Else
                                            A1RB7.Checked = True
                                            A1DB7.Text = Replace(Mid(mscstr, tmp3, tmp2 - tmp3), "SP", "")
                                        End If
                                    End If
                                ElseIf AbilityType = "Blind" Then
                                    Ability_Affect1Target.SelectedIndex = Val(Mid(mscstr, tmp3, tmp2 - tmp3))
                                ElseIf AbilityType = "Silence" Then
                                    Ability_Affect1Target.SelectedIndex = Val(Mid(mscstr, tmp3, tmp2 - tmp3))
                                ElseIf AbilityType = "Poison" Then
                                    Ability_Affect1Damage.SelectedIndex = Val(Mid(mscstr, tmp3, tmp2 - tmp3))
                                ElseIf AbilityType = "Disease" Then
                                    Ability_Affect1Damage.SelectedIndex = Val(Mid(mscstr, tmp3, tmp2 - tmp3))
                                ElseIf AbilityType = "Speed" Then
                                    Ability_Affect1Target.SelectedIndex = Val(Mid(mscstr, tmp3, tmp2 - tmp3))
                                ElseIf AbilityType = "Summon" Then
                                    Ability_Affect1Damage.SelectedIndex = Val(Mid(mscstr, tmp3, tmp2 - tmp3))
                                ElseIf AbilityType = "Stats Modifier" Then
                                    Ability_Affect1Target.SelectedIndex = Val(Mid(mscstr, tmp3, tmp2 - tmp3))
                                ElseIf AbilityType = "Aura" Then
                                    Ability_Affect1Target.SelectedIndex = Val(Mid(mscstr, tmp3, tmp2 - tmp3))
                                ElseIf AbilityType = "Fear" Then
                                    Ability_Affect1Target.SelectedIndex = Val(Mid(mscstr, tmp3, tmp2 - tmp3))
                                ElseIf AbilityType = "Cripple" Then
                                    Ability_Affect1Target.SelectedIndex = Val(Mid(mscstr, tmp3, tmp2 - tmp3))
                                ElseIf AbilityType = "Stun" Then
                                    Ability_Affect1Target.SelectedIndex = Val(Mid(mscstr, tmp3, tmp2 - tmp3))
                                ElseIf AbilityType = "Cure" Then
                                    Ability_Affect1Target.SelectedIndex = Val(Mid(mscstr, tmp3, tmp2 - tmp3))
                                End If
                                tmp3 = tmp2 + 1
                                stepnum += 1
                            ElseIf stepnum = 2 Then
                                If AbilityType = "Damaging" Then
                                    If InStr(Mid(mscstr, tmp3, tmp2 - tmp3), "%") Then
                                        If InStr(Mid(mscstr, tmp3, tmp2 - tmp3), "HP") Then
                                            A1RB1.Checked = True
                                            A1DB1.Text = Replace(Mid(mscstr, tmp3, tmp2 - tmp3), "HP", "")
                                        ElseIf InStr(Mid(mscstr, tmp3, tmp2 - tmp3), "WP") Then
                                            A1RB2.Checked = True
                                            A1DB2.Text = Replace(Mid(mscstr, tmp3, tmp2 - tmp3), "WP", "")
                                        Else
                                            A1RB3.Checked = True
                                            A1DB3.Text = Replace(Mid(mscstr, tmp3, tmp2 - tmp3), "SP", "")
                                        End If
                                    ElseIf InStr(Mid(mscstr, tmp3, tmp2 - tmp3), "+") Then
                                        A1RB4.Checked = True
                                        Dim tmp4 As Integer, tmpa As String = Mid(mscstr, tmp3, tmp2 - tmp3), tmpstep As Integer = 0, tmp5 As Integer
                                        For tmp4 = 1 To Len(tmpa) Step 1
                                            If Mid(tmpa, tmp4, 1) = "d" Then
                                                A1DB4a.Text = Mid(tmpa, 1, tmp4 - 1)
                                                tmpstep += 1
                                                tmp5 = tmp4 + 1
                                            ElseIf Mid(tmpa, tmp4, 1) = "+" Then
                                                A1DB4b.Text = Mid(tmpa, tmp5 - 1, tmp4 - tmp5 + 1)
                                                tmpstep += 1
                                                tmp5 = tmp4 + 1
                                            ElseIf Mid(tmpa, tmp4, 1) = "." Then
                                                A1DB4d.Text = Mid(tmpa, tmp5, tmp4 - tmp5)
                                                tmpstep += 1
                                                tmp5 = tmp4 + 1
                                            ElseIf Mid(tmpa, tmp4, 2) = "HP" Then
                                                A1DB4c.SelectedIndex = Val(Mid(tmpa, tmp5, tmp4 - tmp5))
                                                A1DB4e.SelectedIndex = 0
                                                Exit For
                                            ElseIf Mid(tmpa, tmp4, 2) = "WP" Then
                                                A1DB4c.SelectedIndex = Val(Mid(tmpa, tmp5, tmp4 - tmp5))
                                                A1DB4e.SelectedIndex = 1
                                                Exit For
                                            ElseIf Mid(tmpa, tmp4, 2) = "SP" Then
                                                A1DB4c.SelectedIndex = Val(Mid(tmpa, tmp5, tmp4 - tmp5))
                                                A1DB4e.SelectedIndex = 2
                                                Exit For
                                            End If
                                        Next
                                    Else
                                        If InStr(Mid(mscstr, tmp3, tmp2 - tmp3), "HP") Then
                                            A1RB5.Checked = True
                                            A1DB5.Text = Replace(Mid(mscstr, tmp3, tmp2 - tmp3), "HP", "")
                                        ElseIf InStr(Mid(mscstr, tmp3, tmp2 - tmp3), "WP") Then
                                            A1RB6.Checked = True
                                            A1DB6.Text = Replace(Mid(mscstr, tmp3, tmp2 - tmp3), "WP", "")
                                        Else
                                            A1RB7.Checked = True
                                            A1DB7.Text = Replace(Mid(mscstr, tmp3, tmp2 - tmp3), "SP", "")
                                        End If
                                    End If
                                ElseIf AbilityType = "Healing" Then
                                    Ability_Affect1Healing.SelectedIndex = Val(Mid(mscstr, tmp3, tmp2 - tmp3))
                                ElseIf AbilityType = "Blind" Then
                                    Ability_Affect1Timed.SelectedIndex = Val(Mid(mscstr, tmp3, tmp2 - tmp3))
                                ElseIf AbilityType = "Silence" Then
                                    Ability_Affect1Timed.SelectedIndex = Val(Mid(mscstr, tmp3, tmp2 - tmp3))
                                ElseIf AbilityType = "Poison" Then
                                    If InStr(Mid(mscstr, tmp3, tmp2 - tmp3), "%") Then
                                        If InStr(Mid(mscstr, tmp3, tmp2 - tmp3), "HP") Then
                                            A1RB1.Checked = True
                                            A1DB1.Text = Replace(Mid(mscstr, tmp3, tmp2 - tmp3), "HP", "")
                                        ElseIf InStr(Mid(mscstr, tmp3, tmp2 - tmp3), "WP") Then
                                            A1RB2.Checked = True
                                            A1DB2.Text = Replace(Mid(mscstr, tmp3, tmp2 - tmp3), "WP", "")
                                        Else
                                            A1RB3.Checked = True
                                            A1DB3.Text = Replace(Mid(mscstr, tmp3, tmp2 - tmp3), "SP", "")
                                        End If
                                    ElseIf InStr(Mid(mscstr, tmp3, tmp2 - tmp3), "+") Then
                                        A1RB4.Checked = True
                                        Dim tmp4 As Integer, tmpa As String = Mid(mscstr, tmp3, tmp2 - tmp3), tmpstep As Integer = 0, tmp5 As Integer
                                        For tmp4 = 1 To Len(tmpa) Step 1
                                            If Mid(tmpa, tmp4, 1) = "d" Then
                                                A1DB4a.Text = Mid(tmpa, 1, tmp4 - 1)
                                                tmpstep += 1
                                                tmp5 = tmp4 + 1
                                            ElseIf Mid(tmpa, tmp4, 1) = "+" Then
                                                A1DB4b.Text = Mid(tmpa, tmp5 - 1, tmp4 - tmp5 + 1)
                                                tmpstep += 1
                                                tmp5 = tmp4 + 1
                                            ElseIf Mid(tmpa, tmp4, 1) = "." Then
                                                A1DB4d.Text = Mid(tmpa, tmp5, tmp4 - tmp5)
                                                tmpstep += 1
                                                tmp5 = tmp4 + 1
                                            ElseIf Mid(tmpa, tmp4, 2) = "HP" Then
                                                A1DB4c.SelectedIndex = Val(Mid(tmpa, tmp5, tmp4 - tmp5))
                                                A1DB4e.SelectedIndex = 0
                                                Exit For
                                            ElseIf Mid(tmpa, tmp4, 2) = "WP" Then
                                                A1DB4c.SelectedIndex = Val(Mid(tmpa, tmp5, tmp4 - tmp5))
                                                A1DB4e.SelectedIndex = 1
                                                Exit For
                                            ElseIf Mid(tmpa, tmp4, 2) = "SP" Then
                                                A1DB4c.SelectedIndex = Val(Mid(tmpa, tmp5, tmp4 - tmp5))
                                                A1DB4e.SelectedIndex = 2
                                                Exit For
                                            End If
                                        Next
                                    Else
                                        If InStr(Mid(mscstr, tmp3, tmp2 - tmp3), "HP") Then
                                            A1RB5.Checked = True
                                            A1DB5.Text = Replace(Mid(mscstr, tmp3, tmp2 - tmp3), "HP", "")
                                        ElseIf InStr(Mid(mscstr, tmp3, tmp2 - tmp3), "WP") Then
                                            A1RB6.Checked = True
                                            A1DB6.Text = Replace(Mid(mscstr, tmp3, tmp2 - tmp3), "WP", "")
                                        Else
                                            A1RB7.Checked = True
                                            A1DB7.Text = Replace(Mid(mscstr, tmp3, tmp2 - tmp3), "SP", "")
                                        End If
                                    End If
                                ElseIf AbilityType = "Disease" Then
                                    If InStr(Mid(mscstr, tmp3, tmp2 - tmp3), "%") Then
                                        If InStr(Mid(mscstr, tmp3, tmp2 - tmp3), "HP") Then
                                            A1RB1.Checked = True
                                            A1DB1.Text = Replace(Mid(mscstr, tmp3, tmp2 - tmp3), "HP", "")
                                        ElseIf InStr(Mid(mscstr, tmp3, tmp2 - tmp3), "WP") Then
                                            A1RB2.Checked = True
                                            A1DB2.Text = Replace(Mid(mscstr, tmp3, tmp2 - tmp3), "WP", "")
                                        Else
                                            A1RB3.Checked = True
                                            A1DB3.Text = Replace(Mid(mscstr, tmp3, tmp2 - tmp3), "SP", "")
                                        End If
                                    ElseIf InStr(Mid(mscstr, tmp3, tmp2 - tmp3), "+") Then
                                        A1RB4.Checked = True
                                        Dim tmp4 As Integer, tmpa As String = Mid(mscstr, tmp3, tmp2 - tmp3), tmpstep As Integer = 0, tmp5 As Integer
                                        For tmp4 = 1 To Len(tmpa) Step 1
                                            If Mid(tmpa, tmp4, 1) = "d" Then
                                                A1DB4a.Text = Mid(tmpa, 1, tmp4 - 1)
                                                tmpstep += 1
                                                tmp5 = tmp4 + 1
                                            ElseIf Mid(tmpa, tmp4, 1) = "+" Then
                                                A1DB4b.Text = Mid(tmpa, tmp5 - 1, tmp4 - tmp5 + 1)
                                                tmpstep += 1
                                                tmp5 = tmp4 + 1
                                            ElseIf Mid(tmpa, tmp4, 1) = "." Then
                                                A1DB4d.Text = Mid(tmpa, tmp5, tmp4 - tmp5)
                                                tmpstep += 1
                                                tmp5 = tmp4 + 1
                                            ElseIf Mid(tmpa, tmp4, 2) = "HP" Then
                                                A1DB4c.SelectedIndex = Val(Mid(tmpa, tmp5, tmp4 - tmp5))
                                                A1DB4e.SelectedIndex = 0
                                                Exit For
                                            ElseIf Mid(tmpa, tmp4, 2) = "WP" Then
                                                A1DB4c.SelectedIndex = Val(Mid(tmpa, tmp5, tmp4 - tmp5))
                                                A1DB4e.SelectedIndex = 1
                                                Exit For
                                            ElseIf Mid(tmpa, tmp4, 2) = "SP" Then
                                                A1DB4c.SelectedIndex = Val(Mid(tmpa, tmp5, tmp4 - tmp5))
                                                A1DB4e.SelectedIndex = 2
                                                Exit For
                                            End If
                                        Next
                                    Else
                                        If InStr(Mid(mscstr, tmp3, tmp2 - tmp3), "HP") Then
                                            A1RB5.Checked = True
                                            A1DB5.Text = Replace(Mid(mscstr, tmp3, tmp2 - tmp3), "HP", "")
                                        ElseIf InStr(Mid(mscstr, tmp3, tmp2 - tmp3), "WP") Then
                                            A1RB6.Checked = True
                                            A1DB6.Text = Replace(Mid(mscstr, tmp3, tmp2 - tmp3), "WP", "")
                                        Else
                                            A1RB7.Checked = True
                                            A1DB7.Text = Replace(Mid(mscstr, tmp3, tmp2 - tmp3), "SP", "")
                                        End If
                                    End If
                                ElseIf AbilityType = "Speed" Then
                                    Ability_Affect1Timed.SelectedIndex = Val(Mid(mscstr, tmp3, tmp2 - tmp3))
                                ElseIf AbilityType = "Summon" Then
                                    If InStr(Mid(mscstr, tmp3, tmp2 - tmp3), "%") Then
                                        If InStr(Mid(mscstr, tmp3, tmp2 - tmp3), "HP") Then
                                            A1RB1.Checked = True
                                            A1DB1.Text = Replace(Mid(mscstr, tmp3, tmp2 - tmp3), "HP", "")
                                        ElseIf InStr(Mid(mscstr, tmp3, tmp2 - tmp3), "WP") Then
                                            A1RB2.Checked = True
                                            A1DB2.Text = Replace(Mid(mscstr, tmp3, tmp2 - tmp3), "WP", "")
                                        Else
                                            A1RB3.Checked = True
                                            A1DB3.Text = Replace(Mid(mscstr, tmp3, tmp2 - tmp3), "SP", "")
                                        End If
                                    ElseIf InStr(Mid(mscstr, tmp3, tmp2 - tmp3), "+") Then
                                        A1RB4.Checked = True
                                        Dim tmp4 As Integer, tmpa As String = Mid(mscstr, tmp3, tmp2 - tmp3), tmpstep As Integer = 0, tmp5 As Integer
                                        For tmp4 = 1 To Len(tmpa) Step 1
                                            If Mid(tmpa, tmp4, 1) = "d" Then
                                                A1DB4a.Text = Mid(tmpa, 1, tmp4 - 1)
                                                tmpstep += 1
                                                tmp5 = tmp4 + 1
                                            ElseIf Mid(tmpa, tmp4, 1) = "+" Then
                                                A1DB4b.Text = Mid(tmpa, tmp5 - 1, tmp4 - tmp5 + 1)
                                                tmpstep += 1
                                                tmp5 = tmp4 + 1
                                            ElseIf Mid(tmpa, tmp4, 1) = "." Then
                                                A1DB4d.Text = Mid(tmpa, tmp5, tmp4 - tmp5)
                                                tmpstep += 1
                                                tmp5 = tmp4 + 1
                                            ElseIf Mid(tmpa, tmp4, 2) = "HP" Then
                                                A1DB4c.SelectedIndex = Val(Mid(tmpa, tmp5, tmp4 - tmp5))
                                                A1DB4e.SelectedIndex = 0
                                                Exit For
                                            ElseIf Mid(tmpa, tmp4, 2) = "WP" Then
                                                A1DB4c.SelectedIndex = Val(Mid(tmpa, tmp5, tmp4 - tmp5))
                                                A1DB4e.SelectedIndex = 1
                                                Exit For
                                            ElseIf Mid(tmpa, tmp4, 2) = "SP" Then
                                                A1DB4c.SelectedIndex = Val(Mid(tmpa, tmp5, tmp4 - tmp5))
                                                A1DB4e.SelectedIndex = 2
                                                Exit For
                                            End If
                                        Next
                                    Else
                                        If InStr(Mid(mscstr, tmp3, tmp2 - tmp3), "HP") Then
                                            A1RB5.Checked = True
                                            A1DB5.Text = Replace(Mid(mscstr, tmp3, tmp2 - tmp3), "HP", "")
                                        ElseIf InStr(Mid(mscstr, tmp3, tmp2 - tmp3), "WP") Then
                                            A1RB6.Checked = True
                                            A1DB6.Text = Replace(Mid(mscstr, tmp3, tmp2 - tmp3), "WP", "")
                                        Else
                                            A1RB7.Checked = True
                                            A1DB7.Text = Replace(Mid(mscstr, tmp3, tmp2 - tmp3), "SP", "")
                                        End If
                                    End If
                                ElseIf AbilityType = "Stats Modifier" Then
                                    Ability_Affect1Modifier.SelectedIndex = Val(Mid(mscstr, tmp3, tmp2 - tmp3))
                                ElseIf AbilityType = "Aura" Then
                                    Ability_Affect1Timed.SelectedIndex = Val(Mid(mscstr, tmp3, tmp2 - tmp3))
                                ElseIf AbilityType = "Fear" Then
                                    Ability_Affect1Timed.SelectedIndex = Val(Mid(mscstr, tmp3, tmp2 - tmp3))
                                ElseIf AbilityType = "Cripple" Then
                                    Ability_Affect1Timed.SelectedIndex = Val(Mid(mscstr, tmp3, tmp2 - tmp3))
                                ElseIf AbilityType = "Stun" Then
                                    Ability_Affect1Timed.SelectedIndex = Val(Mid(mscstr, tmp3, tmp2 - tmp3))
                                ElseIf AbilityType = "Cure" Then
                                    Ability_Affect1Timed.SelectedIndex = Val(Mid(mscstr, tmp3, tmp2 - tmp3))
                                End If
                                tmp3 = tmp2 + 1
                                stepnum += 1
                            ElseIf stepnum = 3 Then
                                If AbilityType = "Damaging" Then
                                    Ability_Affect1Target.SelectedIndex = Val(Mid(mscstr, tmp3, tmp2 - tmp3))
                                ElseIf AbilityType = "Healing" Then
                                    Ability_Affect1Target.SelectedIndex = Val(Mid(mscstr, tmp3, tmp2 - tmp3))
                                ElseIf AbilityType = "Blind" Then
                                    Ability_Affect1TimeAmount.Text = Mid(mscstr, tmp3, tmp2 - tmp3)
                                ElseIf AbilityType = "Silence" Then
                                    Ability_Affect1TimeAmount.Text = Mid(mscstr, tmp3, tmp2 - tmp3)
                                ElseIf AbilityType = "Poison" Then
                                    Ability_Affect1Target.SelectedIndex = Val(Mid(mscstr, tmp3, tmp2 - tmp3))
                                ElseIf AbilityType = "Disease" Then
                                    Ability_Affect1Target.SelectedIndex = Val(Mid(mscstr, tmp3, tmp2 - tmp3))
                                ElseIf AbilityType = "Speed" Then
                                    Ability_Affect1TimeAmount.Text = Mid(mscstr, tmp3, tmp2 - tmp3)
                                ElseIf AbilityType = "Summon" Then
                                    Ability_Affect1Timed.SelectedIndex = Val(Mid(mscstr, tmp3, tmp2 - tmp3))
                                ElseIf AbilityType = "Stats Modifier" Then
                                    Ability_Affect1Timed.SelectedIndex = Val(Mid(mscstr, tmp3, tmp2 - tmp3))
                                ElseIf AbilityType = "Aura" Then
                                    Ability_Affect1TimeAmount.Text = Mid(mscstr, tmp3, tmp2 - tmp3)
                                ElseIf AbilityType = "Fear" Then
                                    Ability_Affect1TimeAmount.Text = Mid(mscstr, tmp3, tmp2 - tmp3)
                                ElseIf AbilityType = "Cripple" Then
                                    Ability_Affect1TimeAmount.Text = Mid(mscstr, tmp3, tmp2 - tmp3)
                                ElseIf AbilityType = "Stun" Then
                                    Ability_Affect1TimeAmount.Text = Mid(mscstr, tmp3, tmp2 - tmp3)
                                ElseIf AbilityType = "Cure" Then
                                    Ability_Affect1TimeAmount.Text = Mid(mscstr, tmp3, tmp2 - tmp3)
                                End If
                                tmp3 = tmp2 + 1
                                stepnum += 1
                            ElseIf stepnum = 4 Then
                                If AbilityType = "Damaging" Then
                                    Ability_Affect1Timed.SelectedIndex = Val(Mid(mscstr, tmp3, tmp2 - tmp3))
                                ElseIf AbilityType = "Healing" Then
                                    Ability_Affect1Timed.SelectedIndex = Val(Mid(mscstr, tmp3, tmp2 - tmp3))
                                ElseIf AbilityType = "Poison" Then
                                    Ability_Affect1Timed.SelectedIndex = Val(Mid(mscstr, tmp3, tmp2 - tmp3))
                                ElseIf AbilityType = "Disease" Then
                                    Ability_Affect1Timed.SelectedIndex = Val(Mid(mscstr, tmp3, tmp2 - tmp3))
                                ElseIf AbilityType = "Summon" Then
                                    Ability_Affect1TimeAmount.Text = Mid(mscstr, tmp3, tmp2 - tmp3)
                                ElseIf AbilityType = "Stats Modifier" Then
                                    Ability_Affect1TimeAmount.Text = Mid(mscstr, tmp3, tmp2 - tmp3)
                                End If
                                tmp3 = tmp2 + 1
                                stepnum += 1
                            ElseIf stepnum = 5 Then
                                If AbilityType = "Damaging" Then
                                    Ability_Affect1TimeAmount.Text = Mid(mscstr, tmp3, tmp2 - tmp3)
                                ElseIf AbilityType = "Healing" Then
                                    Ability_Affect1TimeAmount.Text = Mid(mscstr, tmp3, tmp2 - tmp3)
                                ElseIf AbilityType = "Poison" Then
                                    Ability_Affect1TimeAmount.Text = Mid(mscstr, tmp3, tmp2 - tmp3)
                                ElseIf AbilityType = "Disease" Then
                                    Ability_Affect1TimeAmount.Text = Mid(mscstr, tmp3, tmp2 - tmp3)
                                ElseIf AbilityType = "Summon" Then
                                    GB2.Enabled = True
                                    Dim tmp4 As Integer, tmpa As String = Mid(mscstr, tmp3, tmp2 - tmp3), tmpstep As Integer = 0, tmp5 As Integer
                                    For tmp4 = 1 To Len(tmpa) + 1 Step 1
                                        If Mid(tmpa + ".", tmp4, 1) = "." And tmpstep = 0 Then
                                            Ability_Affect1SummonHP.Text = Mid(tmpa, 1, tmp4 - 1)
                                            tmpstep += 1
                                            tmp5 = tmp4 + 1
                                        ElseIf Mid(tmpa + ".", tmp4, 1) = "." And tmpstep = 1 Then
                                            Ability_Affect1SummonWP.Text = Mid(tmpa, tmp5, tmp4 - tmp5)
                                            tmpstep += 1
                                            tmp5 = tmp4 + 1
                                        ElseIf Mid(tmpa + ".", tmp4, 1) = "." And tmpstep = 2 Then
                                            Ability_Affect1SummonSP.Text = Mid(tmpa, tmp5, tmp4 - tmp5)
                                            tmpstep += 1
                                            tmp5 = tmp4 + 1
                                            Exit For
                                        End If
                                    Next
                                End If
                                tmp3 = tmp2 + 1
                                stepnum += 1
                            End If
                        End If
                    Next
                    Exit For
                End If
            Next
        End If
        tmp0 = InStr(AbilityData, "ENDAB#" + npcnum + "(")
        If tmp0 > 0 Then : SND("/GLoading comments...")
            For tmp1 = InStr(AbilityData, "ENDAB#" + npcnum + "(") To Len(AbilityData) Step 1
                If Mid(AbilityData, tmp1, 1) = ")" Then
                    comments.Text = Replace(Mid(AbilityData, InStr(AbilityData, "ENDAB#" + npcnum + "(") + 7 + Len(npcnum), tmp1 - InStr(AbilityData, "ENDAB#" + npcnum + "(") - 7 - Len(npcnum)), "%p45", "")
                    Exit For
                End If
            Next
        End If
        SND("/GMobile loaded.")
    End Sub

    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
        findabilitylist(0, EventArgs.Empty)
        VIRID.Text = LTrim(Str(LoadAbility.Items.Count + 1))
        Button2_Click(0, EventArgs.Empty)
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        AbilityData = GetFileContents(Debugger.DirAbilities)
        Dim aint As Short
        Dim tAbilitydata As String = AbilityData
        Dim overwrite As Boolean = False
        Dim astr As String = ""
        Dim tmp1 As Integer
        Dim tmp2 As Integer
        Dim tmp3 As Integer
        For aint = InStr(AbilityData, "TOTAL#") To Len(AbilityData) Step 1
            If Mid(AbilityData, aint, 1) = "(" Then
                astr = LTrim(Str(Val(Mid(AbilityData, InStr(AbilityData, "TOTAL#") + 6, aint - InStr(AbilityData, "TOTAL#") - 6)) - 1))
                Exit For
            End If
        Next
        If Val(VIRID.Text) <= Val(astr) + 1 Then
            For tmp1 = 1 To Len(tAbilitydata) Step 1
                If Mid(tAbilitydata, tmp1, 6 + Len(VIRID.Text)) = "VIRID#" + VIRID.Text Then
                    tmp2 = tmp1
                End If
                If Mid(tAbilitydata, tmp1, 6 + Len(VIRID.Text)) = "ENDAB#" + VIRID.Text Then
                    For tmp3 = tmp2 To Len(tAbilitydata) Step 1
                        If Mid(tAbilitydata, tmp3, 5) = "%p45)" Then
                            tmp3 += 9
                            Exit For
                        End If
                    Next
                    Exit For
                End If
            Next
            If VIRID.Text <> Val(astr) + 1 Then
                For tmp1 = Val(VIRID.Text) + 1 To Val(astr) + 1 Step +1
                    tAbilitydata = Replace(tAbilitydata, "#" + LTrim(Str(tmp1)) + "(", "#" + LTrim(Str(tmp1 - 1)) + "(")
                    tAbilitydata = Replace(tAbilitydata, "VIRID#" + LTrim(Str(tmp1 - 1)) + "(" + LTrim(Str(tmp1)), "VIRID#" + LTrim(Str(tmp1 - 1)) + "(" + LTrim(Str(tmp1 - 1)))
                Next
            End If
            If Val(VIRID.Text) <= Val(astr) Then
                tAbilitydata = Replace(tAbilitydata, "TOTAL#" + LTrim(Str(Val(astr))) + "(" + LTrim(Str(Val(astr) + 1)) + ")", "TOTAL#" + LTrim(Str(Val(astr))) + "(" + LTrim(Str(Val(astr))) + ")")
                If Len(VIRID.Text) > 1 Then
                    AbilityData = Replace(tAbilitydata, Mid(tAbilitydata, tmp2 - Len(VIRID.Text), tmp3 - tmp2 - Len(VIRID.Text)), "", 1, 1)
                Else
                    AbilityData = Replace(tAbilitydata, Mid(tAbilitydata, tmp2, tmp3 - tmp2), "", 1, 1)
                End If
            Else
                tAbilitydata = Replace(tAbilitydata, "TOTAL#" + LTrim(Str(Val(astr) + 1)) + "(" + LTrim(Str(Val(astr) + 1)) + ")", "TOTAL#" + LTrim(Str(Val(astr))) + "(" + LTrim(Str(Val(astr))) + ")")
                AbilityData = Replace(tAbilitydata, Mid(tAbilitydata, tmp2, Len(tAbilitydata) - tmp2 + 4), "")
            End If
            SaveTextToFile(AbilityData, Debugger.DirAbilities)
            SND("/Gability successfully deleted.")
            If Val(VIRID.Text) <= Val(astr) Then
                LoadAbility.Text = LoadAbility.Items(0)
            Else
                LoadAbility.Text = LoadAbility.Items(0)
            End If
            LoadTheAbility(0, System.EventArgs.Empty)
        Else
            SND("/RERROR: Current ability VIRID doesn't exist.")
        End If
    End Sub
End Class